php - How to seperate a sentence like this -
how separate sentence "comma" , @ last using "and " in php like
"bruce_campbell actor , director , creator , producer , musician."?
now want to show the sentence this...
""bruce_campbell actor , director ,creator , producer , musician.""
you don't want replace last , in string.
$str = "bruce_campbell actor , director , creator , producer , musician.\n"; $except_last_and = substr_count($str, 'and') - 1; $resstr = preg_replace("/and/", ' , ', $str, $except_last_and); echo $resstr;
but gautam3164 correct should google first.
and php manual great resource.
Comments
Post a Comment