I need to split a string that contains commas. I already found something for strings like (str_getcsv
):
'A', 'B with a comma, eh', 'C'
But my string is like this, e.g. with no enclosing characters for the values:
A, B (one, two), C
I need to explode this and obtain:
array(3) {
[0]=>
string(1) "A"
[1]=>
string(12) "B (one, two)"
[2]=>
string(1) "C"
}
I want to split the string using the commas that are not inside parentheses, because that is the only one case in my situation when explode fails.