I’m not sure how to describe or even title this issue but I feel the psuedo code explains it well. I have a multidimensional array called $data (4 levels) and some php code as follows:
$new_array = [];
foreach($data as $a=>$bs){
foreach($bs as $b=$cs){
foreach($cs as $c=$d){
$new_array[$c][$b][$a] = $d;
}
}
}
//I don't know why ...
print_r($new_array);//works, including indices
print_r($new_array['known_index']);//displays nothing, no errors or warnings
print_r($new_array[0]);//displays nothing, no errors or warnings
print_r(current($new_array));//works
I tried enclosing the index variables in double quotes and I have worked around the problem overall. I just don’t know what’s going on and it feels like I should. PHP 8.2
New contributor
user2194067 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.