Is there a way to make this code without warning?
function myFunction($value, $key, &$array) { if (strlen($value)<=2) $array[] = $key.$value; } $a = array("aa", "bbb", "cc", "dd"); $resultA = array(); array_walk($a, 'myFunction', &$resultA);
It works, but it always gives this warning message:
Warning: link follow timed out in path_to \ index.php on line 7
I thought that removing the ampersand from the call should be enough for the warning to disappear, and it is, but, oddly enough, array_walk does not execute the third parameter, if I just point to myFunction as well. To make it work, it must be in the call , but then it issues a warning.
Also, as a workaround, I tried setting php.ini var "allow_call_time_pass_reference" to true, but I'm still getting a warning ...
I am wondering if there could be a better / preferred method of applying custom functions to each element of the WITH array with the pass-by-reference parameter.
php
Toni rosa
source share