Example:
Quote
to
Hello!!! How are you doing?
Quote
Posted 22 January 2007 - 01:25 AM
Quote
Quote
Posted 22 January 2007 - 03:43 AM
Posted 22 January 2007 - 07:57 AM
Posted 22 January 2007 - 06:31 PM
Posted 22 January 2007 - 10:25 PM
Posted 23 January 2007 - 12:40 AM
Posted 23 January 2007 - 03:31 AM
bay, on Jan 22 2007, 11:40 PM, said:
Posted 23 January 2007 - 05:39 PM
Posted 24 January 2007 - 03:11 AM
<?php
$before = 'hello! how are you doing? lolz!';
$punct = array("!", ".", "?");
$array = ucfirst(explode($punct, $before, -1));
$after = implode(",", $array);
echo $after;
?>
Posted 26 January 2007 - 01:21 AM
<?php
$before = 'hello! how are you doing? lolz!';
$array = explode('!', $before);
while(list($key,$string) = each($array)){
$new_array[] = explode('.', $string);
}
$array = array();
while(list($key,$ar) = each($new_array)){
while(list($k,$string) = each($ar)){
$array[] = explode('?', $string);
}
}
$after = implode(",", $array);
echo $after;
?>
I wish i could think of a more recursive way to do that, but none come to mind. Since i haven't tested it, i say good luck and let us know how it turns out.
Posted 26 January 2007 - 05:40 AM
Quote
Posted 26 January 2007 - 02:00 PM
while(list($key,$ar) = each($array)){
$array2[] = implode(',', $array);
}
$after = implode(",", $array2);
Try that.
Posted 29 January 2007 - 06:20 PM
<?php
function formatSentence ( $str )
{
preg_match_all ( '/.*?(\.|\?|!)/', $str, $abc ); // you may need to edit this if you have any other punctuation you want to check for
foreach ( $abc[0] as $a )
{
$rebuilt .= strlen ( $a ) == 1 ? '' : ' ';
$rebuilt .= ucfirst ( trim ( $a ) );
}
$rebuilt = substr ( $rebuilt, 1 );
return $rebuilt;
}
$str = 'hi. my Name is bay!! this is not capitalized!?! BUT THIS IS. woW!';
echo formatSentence ( $str );
?>
0 members, 1 guests, 0 anonymous users