문제

I have something like this:

public static function lengtOfElements($array){
    return array_map(function($item){return strlen($item);},$array);
}

What I want to do is to use strlen($string) directly in array_map, but when I try it it won't work.. Why is the reason?

Something like this:

public static function lengtOfElements($array){
    return array_map(strlen($string),$array);
}
도움이 되었습니까?

해결책

Your syntax is a little off:

return array_map('strlen',$array);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top