Created
August 17, 2016 14:04
-
-
Save joynal/4482588d0bb0fbf0f36380dae6c6879a to your computer and use it in GitHub Desktop.
This file contains 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 | |
// Normal array, can be accessed with indices. | |
$data[] = ['apple', 'orrange', ['banana', 'Papayas', ['Potato', 'Tomato']]]; | |
echo $data[0][0]; // 'apple' | |
echo $data[0][2][0]; // 'banana' | |
echo $data[0][2][2][1]; // 'Tomato' | |
//Associative array, can be accessed with key. | |
$data = [ | |
'A' => 'apple', | |
'B' => 'orrange', | |
'C' => [ | |
'D' => 'banana', | |
'E' => 'Papayas', | |
'F' => [ | |
'G' => 'Potato', 'H' => 'Tomato' | |
] | |
] | |
]; | |
echo $data['A']; // 'apple' | |
echo $data['C']['D']; // 'banana' | |
echo $data['C']['F']['H']; // 'Tomato' | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment