PHP uses copy when writing. This means that if you pass a huge array as a function parameter and only read it (e.g. foreach), you will not write to it, so it does not need to make a copy.
$count = count($huge_array);
for($i = 0; $i < $count $i++) {
$value = 2*$huge_array[$i]/15;
if($value > 3)
$sub_array []= $value;
}
$subarray, ( ), () .
$_, , .
, .
, , PHP.
, , , , $large_array, $large_array .
, PHP .
, , , , , , .
PHP , , , .
function foo(&$data) {
for ($i = 0; $i < strlen($data); $i++) {
do_something($data{$i});
}
}
$string = "... looooong string with lots of data .....";
foo(string);
strlen C . PHP . strlen , ().
, , , , ( ).