Last active
August 29, 2015 13:56
-
-
Save eddmann/9133311 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 | |
foreach ($users as $user) { | |
echo $user['name'] . ' [' . $user['address'] . '] (' . $user['age'] . ')'; | |
} | |
for ($i = 0; $i < count($users); $i = $i + 1) { | |
echo $users[$i]['name'] . ' [' . $users[$i]['address'] . '] (' . $users[$i]['age'] . ')'; | |
} | |
$i = 0; | |
while ($i < count($users)) { | |
echo $users[$i]['name'] . ' [' . $users[$i]['address'] . '] (' . $users[$i]['age'] . ')'; | |
$i = $i + 1; | |
} | |
// The last two could be rewritten for clarity like so. | |
for ($i = 0; $i < count($users); $i = $i + 1) { | |
$user = $users[$i]; // store the current user in the $user variable. | |
echo $user['name'] . ' [' . $user['address'] . '] (' . $user['age'] . ')'; | |
} | |
$i = 0; | |
while ($i < count($users)) { | |
$user = $users[$i]; // store the current user in the $user variable. | |
echo $user['name'] . ' [' . $user['address'] . '] (' . $user['age'] . ')'; | |
$i = $i + 1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment