I’m trying to split a string that is formatted like this:
Value1==Value1||Value2==Value2||…”
at both the == and the || but I’m having trouble with the pipes. I’m able to easily split them at the == but when I try to add in the pipes it’s either not working or splitting it at every character. What pattern should I be using? Thanks!
|is a special character that should be escaped by a backslash. Use\|+to match one or more pipes and split on it if the number of pipes is variable, or\|\|to match two pipes in a regular expression.preg_split('/\|+/', $your_string)However, if it is always two pipes, this is better done with a plain old
explode("||" $your_string)