php smyčka přes pole
$clothes = array("hat","shoe","shirt");
foreach ($clothes as $item) {
echo $item;
}
foreach v php
$arr = array(
'key1' => 'val',
'key2' => 'another',
'another' => 'more stuff'
);
foreach ($arr as $key => $val){
//do stuff
}
//or alt syntax
foreach ($arr as $key => $val) :
//do stuff here as well
endforeach;
php foreach echo hodnota klíče
foreach($page as $key => $value) {
echo "$key is at $value";
}
foreach v php
<?php
// Declare an array
$arr = array("green", "blue", "pink", "white");
// Loop through the array elements
foreach ($arr as $element) {
echo "$element ";
}
?>
php foreach asociativní pole
$arr = array(
'key1' => 'val1',
'key2' => 'val2',
'key3' => 'val3'
);
foreach ($arr as $key => $val) {
echo "$key => $val" . PHP_EOL;
}
php pro každý schleife
foreach ($name as $key => $value) {
echo ("Position {$key} enthält {$value}. ");
}