How about iterating though the strings and putting string values and
lengths in an array:

[begin untested code]
$strings = array('i','am','who');
$string_count = array();
foreach ($strings as $string) {
 $string_count['value'][] = $string;
 $string_count['length'][] = strlen($string);
}
array_multisort($string_count['length'],SORT_ASC,SORT_NUMERIC,$string_count['value']);

[/end untested code]

This'll take an array of strings and sort them from shortest to longest.

There may be some other function already made, this was just off the
top of my head.


On Tue, 21 Dec 2004 16:18:52 -0500 (EST), Russell P Jones
<[EMAIL PROTECTED]> wrote:
> Any idea how to sort an array by string length?
> 
> Russ Jones
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 


-- 
<<--------------------------------------------------------
Jasper Howard - Database Administration
ApexEleven.com
530 559 0107
------------------------------------------------------->>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to