php Parsing A String With Multiple Delimiters [duplicate]
I want to parse string in php with multiple delimiters I use this code
$pattern = '/[, ]/';
$array = preg_split( $pattern, $string);
This work fine , but I want to use and "[" and "]" as delimiters!!
How can I include this delimiters in $pattern. I try with $pattern = '/[, []]/'; and $pattern = '/[, ]/'; but error occurred.
Thanks
Escaping the brackets should work.
\[
Related: preg_quote()
Edit: use json_decode() instead.
加载中,请稍侯......
精彩评论