Posted By

jatkins on 02/15/11


Tagged

sort array String text Value length strlen


Versions (?)

Find the longest string in an array


 / Published in: PHP
 

Released into the public domain.

  1. function find_longer_value($first, $second) {
  2. return strlen($first) > strlen($second);
  3. }
  4.  
  5. function longest_value($array) {
  6. usort($array, 'find_longer_value');
  7. return $array[count($array)-1];
  8. }

Report this snippet  

You need to login to post a comment.