Php foreac

Příklady kódu

30
0

php foreach

$arr = ['Item 1', 'Item 2', 'Item 3'];

foreach ($arr as $item) {
  var_dump($item);
}
13
0

foreach php

foreach (array_expression as $value)
    statement
foreach (array_expression as $key => $value)
    statement
7
0

foreach loop array php

foreach (array as $value){ 
  //code to be executed; 
  print("value : $value");
} 

foreach (array as  $key => $value){ 
  //code to be executed; 
  print("key[$key] => $value");
} 
0
0

pro každou smyčku php


<?php 
$colors = array("red", "green", "blue", "yellow"); 

 
foreach ($colors as $value) {
  echo "$value <br>";
}
?>  
0
0

pro každý php


<?php
$array = [
    [1, 2],
    [3, 4],
];

foreach ($array as list($a, $b)) {
    // $a contains the first element of the nested array,
    // and $b contains the second element.
    echo "A: $a; B: $b\n";
}
?>

0
0

php foreac

<?php
$arr = array(1, 2, 3, 4);
foreach ($arr as &$value) {
    $value = $value * 2;
}
// $arr is now array(2, 4, 6, 8)
unset($value); // break the reference with the last element
?>

V jiných jazycích

Tato stránka je v jiných jazycích

Русский
..................................................................................................................
English
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................
Балгарскі
..................................................................................................................
Íslensk
..................................................................................................................