Read the longest string from an array in PHP 5.3

前端 未结 2 1086

Here is part of the code.

$DatabaseArray=Array("Cooking","look","I cant","Walking the dog to the park","washing&q         


        
2条回答
  •  天涯浪人
    2020-12-03 20:31

    $lengths = array_map('strlen', $DatabaseArray);
    $maxLength = max($lengths);
    $index = array_search($maxLength, $lengths);
    echo $DatabaseArray[$index];
    

提交回复
热议问题