I have an array in PHP that I encode to json:
$jsonOutput = json_encode($output);
Then in my javascript, I use this to parse it:
var jsonOutput = JSON.parse('<?php echo $jsonOutput; ?>');
My output looks like this in the Chrome console:
Ultimately, I have two arrays, and I'm trying to write a compare between the two to show if there are any items in the first array that aren't in the second, but I'm not sure how to reference red
and orange
here.
I tried console.log(jsonOutput[0])
but I get undefined
.
Also, as a side note, does anyone have any good resources for reading up on arrays in javascript and all their ins-and-outs? It seems to be one aspect that I'm struggling with lately...