I have a .json file with some data I'm trying to extract. What I need to know is how I would go about making the below variable dynamic.
$MapData['MapData']['0,0']['type'];
What I need to know is how I would replace the 0,0 with $x,$y variables. I've tried to use variable as a variable name.
$MapString = "MapData['MapData']['".$x.",".$y."']['type']";
$MapStringData = $$MapString;
I was unsuccessful in getting this to work. Is there something I'm missing or not doing right?
If you can rely on the last cell having the highest row/column number as the key, then you first can extract the keys for the MapData, and with the last (using
end) element split it usingexplode()with a,. This useslist()to assign the two values to the rows and column fields...