PHP:在嵌套的foreach中访问父键[关闭]

EDIT*************

There was no issue with my loop, turns out I just had one of those tricky "Quotation mark' errors. I'd like to blame it on Monday morning but well, that was just dumb haha. Well I guess here's an example of what works lol:

What I'm doing is this:

$array = [
  0 => [
    0 => 1,
    1 => 3
  ],
  1 => [
    0 => 5,
    1 => 4
  ]
]

foreach($array as $key=>$value){
  foreach($value as $_key=>$_value){
    echo "Parent key: " . $key . " Child value: " . $_value; 
  }
}

This works great. palm in face

you have a typo error in first foreach loop

foreach($array as $key=>$value){

it should be $array and not array

I think that you forgot a $ before array.

Replace (You forgot a $ before array.)

foreach(array as $key=>$value){
 foreach($value as $_key=>$_value){
 echo "Parent key: " . $key . " Child value: " . $_value; 
  }
 }

With

  foreach($array as $key=>$value){
   foreach($value as $_key=>$_value){
    echo "Parent key: " . $key . " Child value: " . $_value; 
}
}