Page 1 of 1

multiple string separator for explode

Posted: Sun Jun 03, 2007 12:04 am
by icesha
hello, i need some help regarding explode function. I want to use a multiple string separator for my explode function. Im exploding sentences with different punctuation marks like "!" or "?" or ","
what i have done is just for sentences that ends with a period.

but when i used separate explode syntx it will just output everything.
please help me. thank you.

Here is an example:

Code: Select all

//this is a code
<?
$var= $_POST['textfield'];
$mypar=explode('.',$var);
//sentence
foreach($mypar as $b)
{
echo "$b - This is a sentence - Ends with a period";
echo "<br/>";
echo "<br/>";
}

?>

Posted: Sun Jun 03, 2007 12:07 am
by maliskoleather
look into preg_split();

Posted: Sun Jun 03, 2007 5:01 am
by s.dot
You should also look into separating on a period and a space, instead of a period. Thinks like Mr., Dr. Ave., $19.99, ... (elipses), etc, all have valid usage of periods within a sentence.