preg_split() function operates like split(), except that regular expressions are accepted as input parameters for pattern. : preg_split « String « PHP






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;
?>
  
  








Related examples in the same category

1.Calculating average word length
2.preg_split() Flags
3.preg_split.php
4.Discarding empty elements with preg_split()
5.How preg_split() can be used:
6.Limiting the number of returned elements with preg_split()
7.Parsing a date with preg_split()
8.Using preg_split()
9.Using preg_split() to Break Up Strings