Associative Array
Submitted by kingwash on Thursday, June 28, 2018 - 20:11.
This is a simple nested associative array and how to display the elements.
In this array, we have three nested arrays. We will loop through using an array $key to display the elements within the array.
So we will create a foreach loop within another foreach loop to get the elements.
- <?php
- // define associative array
- // associative array within associative array
- // print array contents
- foreach($data as $key=> $val)
- {
- foreach($val as $key=> $t)
- echo $key.':'.' '.$t.'<br>';
- }
- ?>
Add new comment
- 59 views