Assign the key a value (apparently named $billdate) in the outer foreach loop.

foreach( $array as $billdate => $date) { 
    foreach( $date as v) {         
        echo $billdate; // Prints something like Nov 18, 2011
    }            
} 
Answer from nickb on Stack Overflow
🌐
PHP
php.net › manual › en › control-structures.foreach.php
PHP: foreach - Manual
Reference to a $value of the last array element remain even after the foreach loop. It is recommended to destroy these using unset(). Otherwise, the following behavior will occur: <?php $arr = [1, 2, 3, 4]; foreach ($arr as &$value) { $value = $value * 2; } // $arr is now [2, 4, 6, 8] var_dump($arr); // without an unset($value), $value is still a reference to the last item: $arr[3] echo "\nAnother loop:\n"; foreach ($arr as $key => $value) { // $arr[3] will be updated with each value from $arr...
🌐
Tutorial Republic
tutorialrepublic.com › faq › foreach-loop-through-multidimensional-array-in-php.php
Foreach Loop through Multidimensional Array in PHP
<?php // Multidimensional array ... // Printing all the keys and values one by one $keys = array_keys($superheroes); for($i = 0; $i < count($superheroes); $i++) { echo $keys[$i] ....
🌐
sebhastian
sebhastian.com › php-foreach-multidimensional-array
How to loop through a multidimensional array using foreach in PHP | sebhastian
December 2, 2022 - <?php // Create a multidimensional ... { print "Array index : {$index}"; print PHP_EOL; foreach ($member as $key => $value) { print "{$key} : {$value}"; print PHP_EOL; } }...
🌐
Developer Drive
developerdrive.com › home › php arrays: array functions and multidimensional arrays
PHP Arrays: Array Functions and Multidimensional Arrays - Developer Drive
January 10, 2022 - The easiest way to loop through a multidimensional array is to nest two foreach loops; the outer loop goes through each outer array element, and the inner loop goes through each inner array element within the selected outer element. <? foreach ($arrBooks as $obj_key =>$book) { echo "$obj_key ...
🌐
GeeksforGeeks
geeksforgeeks.org › php › how-to-use-foreach-loop-with-multidimensional-arrays-in-php
How to Use Foreach Loop with Multidimensional Arrays in PHP? - GeeksforGeeks
July 23, 2025 - ... <?php $students = array( ... "Age" => 28) ); foreach ($students as $student) { foreach ($student as $key => $value) { echo "$key => $value\n"; } echo "\n"; } ?>...
🌐
CodeSignal
codesignal.com › learn › courses › multidimensional-arrays-and-their-traversal-in-php › lessons › multidimensional-arrays-and-their-traversal-in-php
Multidimensional Arrays and Their Traversal in PHP
<?php $array = [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ]; // Removing the second column $newArray = []; foreach ($array as $row) { $newRow = []; foreach ($row as $key => $value) { if ($key !== 1) { $newRow[] = $value; } } $newArray[] = $newRow; } foreach ($newArray as $floor) { foreach ($floor as $unit) { echo $unit .
Find elsewhere
🌐
ZetCode
zetcode.com › php › foreach
PHP foreach - looping over array in PHP with foreach statement
The next example loops over an array/dictionary. ... <?php $benelux = [ 'be' => 'Belgium', 'lu' => 'Luxembourgh', 'nl' => 'Netherlands' ]; foreach ($benelux as $key => $value) { echo "$key is $value\n"; }
🌐
Delft Stack
delftstack.com › home › howto › php › php foreach multidimensional array
How to Use Foreach Loop in Multidimensional Array in PHP | Delft Stack
February 2, 2024 - In the nested loop, write the $bike variable as an array and set the $num and $value as key and value. Inside the nested loops, print the variables $num, $number, and $value as shown in the example below. Therefore, we can use the nested foreach loop to access the elements of a multidimensional array in PHP.
🌐
FlatCoding
flatcoding.com › home › php multidimensional arrays: data manipulation
PHP Multidimensional Arrays: Data Manipulation - FlatCoding
April 15, 2025 - Let’s look at an example: <?php // Loop through each product in the $products array foreach ($products as $product) { // Loop through each key-value pair in the product array foreach ($product as $key => $value) { // Print out the key-value ...
🌐
GeeksforGeeks
geeksforgeeks.org › php › multidimensional-associative-array-in-php
Multidimensional Associative Array in PHP - GeeksforGeeks
July 12, 2025 - Using foreach loop: We can use foreach loop to retrieve value of each key associated inside the multidimensional associative array. Example: ... <?php $languages = array(); $languages['Python'] = array( "first_release" => "1991", "latest_release" ...
🌐
HCL GUVI
studytonight.com › php-howtos › foreach-loop-through-multidimensional-array-in-php
HCL GUVI | Learn to code in your native language
Take your tech career to the next level with HCL GUVI's online programming courses. Learn in native languages with job placement support. Enroll now!