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

Introduction

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..


techstudy.org

HP 15 Core i3 7th gen Laptop(4GB, 1TB HDD, Windows 10) | Rs. 31,490

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

Result

python language techstudy.org

     





Related Topics




Popular Posts