I'm perplexed as to how this is not erroring on my server with the highest error reporting to be shown? Any insight is gladly welcomed.
$myArray = ['first' => '1A', 'second' => '2A', 'first' => '2A', 'second' => '2B'];
foreach($myArray as $value) {
echo $value['first'] . "<br />";
}
Outputted:
1A
2A
You have duplicated array Keys and this is not allowed on arrays Check Arrays
You have to reformat Your array to be like this
$myArray = [['first' => '1A', 'second' => '2A'], ['first' => '2A', 'second' => '2B']];
foreach($myArray as $key => $value) {
echo $value['first']."<br / >";
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With