$test = array('1' => 1, '2' => 2, '3' => 3, '4' => 4, '5' => 5); print_r($test); foreach ($test as $key => $value) { echo "{$key} => {$value}\n"; }
Array ( [1] => 1 [2] => 2 [3] => 3 [4] => 4 [5] => 5 ) 1 => 1 2 => 2 3 => 3 4 => 4 5 => 5
$test = array('1' => 1, '2' => 2, '3' => 3, '4' => 4, '5' => 5); foreach ($test AS &$value) { // - . } print_r($test); foreach ($test as $key => $value) { echo "{$key} => {$value}\n"; }
Array ( [1] => 1 [2] => 2 [3] => 3 [4] => 4 [5] => 5 ) 1 => 1 2 => 2 3 => 3 4 => 4 5 => <b>4</b>
Source: https://habr.com/ru/post/59299/
All Articles