Joshi Joshi - 9 months ago 63
PHP Question

Accessing Mulit-dimensional non indexed array

I am getting this array with a


array (size=1)
'' =>
array (size=2)
'classkey' => string 'domcno' (length=6)
'status' => string 'available' (length=9)

Now I want to access the value of
from the array, I have tried it multiple ways, but couldn't get the result.

I have attempted like below without any success;


foreach($data as $key => $val){
echo $data[$key];

Answer Source
foreach($data as $key => $val){
    $classkey = $val['classkey'];
    $status = $val['status'];

You were close, in this case $key is '' and $val is the array at that index. If you're fine to iterate over it like that, then use $val.