Values & References3 / 16
Up next

Arrays pass by value

<?php
declare(strict_types=1);
// the array argument is copied on entry
function appendZero(array $v): void {
    $v[] = 0;
}
$nums = [1, 2];
appendZero($nums);
// caller's array is untouched
print_r($nums);
What you're solving

a function gets its own copy