Anonymous function breaking when upgrading PHP -


the following code breaking when switched servers/upgrading php 5.3 5.4:

function arrayvalrecursive($key, array $arr, $string=false){     $val = array();     array_walk_recursive($arr, function($v, $k) use($key, &$val){         if($k == $key) array_push($val, $v);     });     if($string==true){       return count($val) > 1 ? $val : array_pop($val);     }     else {       return $val;     } } 

i'm receiving parse error: syntax error, unexpected t_function error, seems due anonymous function in array_walk_recursive line.

how write function differently avoid issue, , why happening when upgrading php?

thanks

you using php 5.2 can tell.

running phpinfo() code <? echo phpinfo(): ?> detect version. tests using php 5.2 - 5.5 occurs in php 5.2 before lambda functions existed.

of course know our comments, future visitors.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -