Q:

Write a PHP script to get the shortest/longest string length from an array

0

Write a PHP script to get the shortest/longest string length from an array

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

PHP is a server scripting language, and It is a powerful tool for making interactive and dynamic Web-pages. I have used WampServer 2.2 for following excercise..

<?php
$my_array = array("bmw","jeep","dastun","ferrari","Honda");
$new_array = array_map('strlen', $my_array);
 
echo "The shortest array length is ". min($new_array)."<br>". // min() function 
" The longest array length is " . max($new_array).'.'; //max() function
?>

Result:

The shortest array length is 3
The longest array length is 7.

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now