Share the code
function commaSplit($s =null, $n=- 1) { return preg_split( '/[\s,]+/',$s ,$n, PREG_SPLIT_NO_EMPTY); } //usage print_r( commaSplit('book, garden , , ,, carrot, food, ,' )); //result Array ( [0] => book [1] => garden [2] => carrot [3] => food )
No comments:
Post a Comment