I need to get data from an array, but the output always varies so sometimes it has more empty keys etc.
$id = "1";
$url = file_get_contents("http://example.com/?api={$id}");
$json = json_decode($url, true);
foreach($json as $data)
{
echo $data[0][0]["test"];
}
The problem is that to print values from it have to always put the number of empty keys first like echo $data[0][0]["test"];
How can I make it possible to only write echo $data["test"];
under any circumstance no matter how many empty keys there are?
EDIT: The json array
[
[
{
"test: "testing"
}
]
]