David T-G wrote:

Hi, all --

I have an array like

  $a =
    array
    (
      'key' =>
        array
        (
          'title' => "Topic Title",
          'content' => "Topic Content",
        ),
        ...
    ) ;

and I'd like to sort the whole thing not on the keys but on the titles.
It sounds like array_multisort should do exactly what I want, but I can't
seem to get it to work.

usort is what you need:


function cmp($a, $b)
{
   if ($a['title'] == $b['title']) {
       return 0;
   }
   return ($a['title'] < $b['title']) ? -1 : 1;
}

usort($a, "cmp");

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



Reply via email to