Friday, July 13, 2012

PHP: split string by multiple delimiters


Use preg_split() method:

$pattern = '/[;,]/'; //regex
$string = "something here ; and there, oh,that's all!";
$myArray = preg_split( $pattern, $string );


Reference:
http://stackoverflow.com/questions/1452777/how-to-split-a-string-by-multiple-delimiters-in-php

No comments: