Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Loop statement: foreach
<?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
You can’t perform that action at this time.