Created
May 5, 2021 08:29
-
-
Save A973C/71d33d9ef585db4694148e16d7e6d639 to your computer and use it in GitHub Desktop.
Two dimensional array #php
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 | |
$array = array( | |
0 => array( | |
'name' => 'John Doe', | |
'email' => '[email protected]' | |
), | |
1 => array( | |
'name' => 'Jane Doe', | |
'email' => '[email protected]' | |
), | |
); | |
foreach ( $array as $groupid => $fields) { | |
echo "hi element ". $groupid . "\n"; | |
echo ". name is ". $fields['name'] . "\n"; | |
echo ". email is ". $fields['email'] . "\n"; | |
$i = 0; | |
foreach ($fields as $field) { | |
echo ". field $i is ".$field . "\n"; | |
$i++; | |
} | |
} | |
?> |
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
hi element 0 | |
. name is John Doe | |
. email is [email protected] | |
. field 0 is John Doe | |
. field 1 is [email protected] | |
hi element 1 | |
. name is Jane Doe | |
. email is [email protected] | |
. field 0 is Jane Doe | |
. field 1 is [email protected] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment