note 87730 deleted from function.max by colder

From: Date: Tue, 20 Jan 2009 15:05:07 +0000
Subject: note 87730 deleted from function.max by colder
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-149524@lists.php.net to get a copy of this message
Note Submitter: McCookieM ---- Just discovered that max() can find the longest strings in an array of strings. <?php $test=array("a","bc","def","ghij","kl","mno"); echo 'Longest string in test array is : '.max($test); ?> Will output : Longest string in test array is : ghij This appears to take the first occurance of the longest string so if we added "pqrs" to the end of the array is would still return "ghij". This wasn't clear but kind of hinted at in the function description. Obviously, this also works for min() for the shortest string.

« previous php.notes (#149524) next »