Hi all~
I'm trying to use preg_split() to return substrings split on the "|" character (the bitwise "or" operator). It's (obviously) seeing the expression as [empty string "or" empty string].....
Does anyone know how to escape it so it splits on the "|" as a character?
Thanks in advance!
Zoomerz
You should be able to escape it with a backslash.
Hi Tom; I tried something like;
$myArray = preg_split('|',$myStr); but it didn't work either, still returning every character....any other ideas?
Thanks! zoomerz
got it, I bracketed the '|' like this '[|]' and it works, Thanks for the help 🙂
Yeah, you missed out the regexp delimiters PCRE regexps need.
But you wouldn't have had any of this trouble if you'd looked at explode()