I need to create an array or an object from a given string. String is received in a post and is a serialized js object.
I get a string like:
{'id': n, 'propery 1': 'something', 'propery 2': 'something else', etc.}
or
{'whatever': bla bla, etc.} (without the id part).
I need to transform that in a php object or array or… something usable.
I’m aware that I could extract the substrings or explode(': ', $string) but I not really efficient. The received strings are really close to json format (with only 1 or 2 exceptions that I can treat separately).
Use json_decode($string) ==> php Object (or array if you force with a param).
Use json_encode($array) ==> string