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);
Note that the $lengths
array is unsorted, so you can easily retrieve the corresponding number for each string length.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…