Let simplify the question:
All I need is to explode() string by a comma between brackets. The problem is that elements selected by comma can have a comma in itself, thus simple exploding won't work. I am not asking how to decode JSON.
The number of arguments, their type will always be different, e.g.
('foo')
('bar', NULL)
({"JSON": "data"}, 'test')
Assuming that I have this part of the code:
({"class": "navigation", "id": "navigation"}, NULL, 'bar' /* [..] */)
Can anyone suggest a regex (or alternative method) to get all the comma separated entries (as string)? The problem is that variables can contain commas in itself. Thus, I assume this requires recursion.
Expected result would be an array containing following entries:
{"class": "navigation", "id": "navigation"}
NULL
'bar'
After many hours of work, I have come across that PHP will fail to parse JSON string containing NULL (uppercase null). That was what caused the following code not to work. However, simply replacing NULL to null solved the problem.