更新时间:2022-11-11 10:21:27
Seems like you should use an array_map()
// Convert array to an array of string lengths
$lengths = array_map('strlen', $data);
// Show min and max string length
echo "The shortest is " . min($lengths) .
". The longest is " . max($lengths);
请注意,$lengths
数组未排序,因此您可以轻松地为每个字符串长度检索相应的数字.
Note that the $lengths
array is unsorted, so you can easily retrieve the corresponding number for each string length.