I have the following script to get search results from an API and then slice the array and dump it, I am having trouble decoding the JSON into an array, it returns Arr
Try json_decode
$array = json_decode($data, true);
Then you'll get an array instead of an object.
Example #1 json_decode() examples
The above example will output:
object(stdClass)#1 (5) {
["a"] => int(1)
["b"] => int(2)
["c"] => int(3)
["d"] => int(4)
["e"] => int(5)
}
array(5) {
["a"] => int(1)
["b"] => int(2)
["c"] => int(3)
["d"] => int(4)
["e"] => int(5)
}