function heaviside(&$value, $key, &$array)
{
if($key > 0)
$value = $array[$key-1].$array[$key];
}
function test_heaviside()
{
for($i=0; $i<10; $i++)
{
$array[$i] = $i;
}
array_walk($array, 'heaviside', &$array);
print_r($array);
}
test_heaviside();
My problem is that the above code will generate this warning:
PHP Warning: Call-time pass-by-reference has been deprecated - argument passed by value; If you would like to pass it by reference, modify the declaration of array_walk(). If you would like to enable call-time pass-by-reference, you can set allow_call_time_pass_reference to true in your INI file. However, future versions may not support this any longer.
And if I remove & in &$array in my call to array_walk, this function will not return this correct result. In the first case, where it works, it returns this result:
[0] => 0 [1] => 01 [2] => 012 [3] => 0123 [4] => 01234 [5] => 012345 [6] => 0123456 [7] => 01234567 [8] => 012345678 [9] => 0123456789
Whereas if I remove & it returns:
[0] => 0 [1] => 01 [2] => 12 [3] => 23 [4] => 34 [5] => 45 [6] => 56 [7] => 67 [8] => 78 [9] => 89
I need help understanding this or simply to find a solution other than changing .ini.