RE: Sort by string length...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Russell P Jones wrote:
> Any idea how to sort an array by string length?

Use usort() in conjunction with a user defined function that compares the length of
both strings using strlen().  If brevity at the (possible) expense of clarity is
your thing, you can even use create_function() as your callback argument to usort()
to make this a one-liner.  Of course if that were your sort of thing you'd probably
be using perl instead of PHP. :)

HTH

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux