On Fri, Feb 07, 2003 at 11:09:10AM -0600, Shawn McKenzie wrote:
> 
> What else does ksort() do to the array???  Does it matter that my keys look
> like this: '[some-text]'???
> 
> This works great:
> 
> foreach($myarray as $key => $val) {
> echo "$key = $val";
> }
> 
> This gives me a Warning: Invalid argument supplied for foreach():
> 
> $sortedarray = ksort($myarray);
> foreach($sortedarray as $key => $val) {
> echo "$key = $val";
> }
> 
> Any ideas???

Inserting a print_r into your test script tells you the problem, as does
a closer look at http://www.php.net/ksort .

You're assuming ksort()'s return value is the sorted array.  It is not.
Try something more along the lines of:

    $testarray=array(
        "[three]" => 3,
        "[two]" => 2,
        "[one]" => 1,
    );
    ksort($testarray);
    print_r($testarray);

-- 
  Paul Chvostek                                             <[EMAIL PROTECTED]>
  Operations / Abuse / Whatever
  it.canada, hosting and development                   http://www.it.ca/


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

Reply via email to