note 88503 deleted from function.array-flip by danbrown
| From: | danbrown@php.net | Date: | Tue, 27 Jan 2009 13:53:09 +0000 |
| Subject: | note 88503 deleted from function.array-flip by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-149844@lists.php.net to get a copy of this message | ||
Note Submitter: dead dot screamer at seznam dot cz
----
corz at corz dot org:
your function is really very funny, but classical way must be faster:
<?php
function getLongestValue($array)
{
$max=0;
$longest='';
foreach($array as $value)
{
$len=strLen($value);
if($len>$max)
{
$max=$len;
$longest=$value;
}
}
return $longest;
}
$array=array(
'input'=>'submit',
'textarea'=>'Some long spiel of text\r\na textarea, probably',
'another-input'=>'make me longer',
'and'=>'another',
'etc'=>'etc.',
);
header('Content-Type: text/plain');
var_Dump(get_Longest_Value($array));
?>
Output:
string(47) "Some long spiel of text\r\na textarea, probably"