programming-examples/php/Arrays/PHP script to get the shortest or longest string length from an array.php

7 lines
310 B
PHP
Raw Normal View History

2019-11-15 12:59:38 +01:00
<?php
$my_array = array("abcd","abc","de","hjjj","g","wer");
$new_array = array_map('strlen', $my_array);
// Show maximum and minimum string length using max() function and min() function
echo "The shortest array length is " . min($new_array) .
". The longest array length is " . max($new_array).'.';
?>