There are many pre-defined functions to manipulate the sort order of arrays and it's keys. However sometimes, to fit special needs, you just have to do it manually. Here's the useful PHP reference manual links to better understand what's available.

http://www.php.net/manual/en/ref.array.php

http://www.php.net/manual/en/function.asort.php
http://www.php.net/manual/en/function.arsort.php

http://www.php.net/manual/en/function.ksort.php
http://www.php.net/manual/en/function.krsort.php

http://www.php.net/manual/en/function.usort.php
http://www.php.net/manual/en/function.uksort.php


HTH,
Jason k Larson


David T-G wrote:
Hi, all --

If I have an associative array $a like

  Array
  (
    [t] => temp1
    [u] => ugh
    [m] => moo
  )

is there any way to re-order the keys so that

  foreach (array_keys($a) as $k)
    { print "$k\n" ; }

will print

  t
  m
  u

for me?  At the moment it seems my only option is

  sort(array_keys($a))

and that's a start but finding another order spec would be lovely...


TIA & HAND

:-D


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

Reply via email to