Last active
October 26, 2015 22:12
-
-
Save drukaman/d52d0d0e03601ee256bb to your computer and use it in GitHub Desktop.
Recursive and multi-dimensional arrays
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $fruits = array ( "fruits" => array ( "a" => "orange", | |
| "b" => "banana", | |
| "c" => "apple" | |
| ), | |
| "numbers" => array ( 1, | |
| 2, | |
| 3, | |
| 4, | |
| 5, | |
| 6 | |
| ), | |
| "holes" => array ( "first", | |
| 5 => "second", | |
| "third" | |
| ) | |
| ); | |
| // Some examples to address values in the array above | |
| echo $fruits["holes"][5]; // prints "second" | |
| echo $fruits["fruits"]["a"]; // prints "orange" | |
| unset($fruits["holes"][0]); // remove "first" | |
| // Create a new multi-dimensional array | |
| $juices["apple"]["green"] = "good"; | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment