EDIT: I was taking this too literally- a commenter correctly pointed out that the + in the querystring is just a url encoding for a space- sorry for the confusion
I need to split a string by a couple delimiters (, and +). The background is I'm saving query string parameters into $query (like so: $query = $_GET["geo"];), and I want to break them into different parts based on , and + (and not space because towns and states can have multiple words):
?geo=Cambridge+Massachusetts or
?geo=Cambridge,Massachusetts
Reading here I'm trying it like so:
$query_array = preg_split("/[+,]+/", $query, -1, PREG_SPLIT_NO_EMPTY);
It's splitting for , but not for +
Do I need to escape it? Or is there fundamentally a different way I should be doing this?
Thanks in advance for any help!