Skip to main content

PHP program to check string length from an array


<?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).'.';

?>

Comments

Popular posts from this blog

PHP program to convert word to digit

<?php function word_digit($word) {     $warr = explode(';',$word);     $result = '';     foreach($warr as $value){         switch(trim($value)){             case 'zero':                 $result .= '0';                 break;             case 'one':                 $result .= '1';                 break;             case 'two':                 $result .= '2'; ...