Mega Code Archive

 
Categories / Php / Strings
 

Preg_split() function operates like split(), except that regular expressions are accepted as input parameters for pattern

Its syntax is: array preg_split (string pattern, string string [, int limit [, int flags]]) If limit is specified, then only limit number of substrings are returned.  <? $user_info = "+J+++G+++++w"; $fields = preg_split("/\+{1,}/", $user_info); while ($x < sizeof($fields)) :    print $fields[$x]. "<br>";    $x++; endwhile; ?>