name: TaniaHermione Grangers wand is vine, 10 and 3/4 inches, with a dragon heartstring core. Converting a PHP object or array into JSON. The function jsondecode() provides an optional boolean second-argument that if passed as true converts objects into PHP associative arrays. Using the example from above, and decoding it as such, the elements can be accessed using the respective keys. PHP Array, JSON, and Object. PHP Array Intro PHP Array Access . Convert an array to json by using jsondecode() function. Example 1:Simple Array. Convert JSON String to PHP Array or Object. PHP > 5.2.0 features a function, jsondecode, that decodes a JSON string into a PHP variable.