Created
June 10, 2019 14:17
-
-
Save flaviors200/b33b9583e664ae1b6de06f2ce7e7c138 to your computer and use it in GitHub Desktop.
Loop statement: foreach
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 | |
$colors = ['blu', 'giallo', 'verde', 'rosso', 'bianco']; | |
// Prima versione | |
foreach ($colors as $color) { | |
echo "$color\n"; | |
} | |
// Seconda versione | |
$days = [ | |
'lun' => 'lunedì', | |
'mar' => 'martedì', | |
'mer' => 'mercoledì', | |
'gio' => 'giovedì', | |
'ven' => 'venerdì', | |
'sab' => 'sabato', | |
'dom' => 'domenica' | |
]; | |
foreach ($days as $key => $value) { | |
echo "$key = $value\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment