Zubrag.com
March 26, 2019, 10:58:07 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Array keys are not sorted  (Read 5524 times)
zubrag
Administrator
Hero Member
*****
Posts: 788


WWW
« on: May 07, 2007, 10:30:59 AM »

Do not expect arrays in php to be sorted by the key by default.

Consider following example:

$mylist = array(2=>'b', 3=>'c');
$mylist[1] = 'a';

foreach($mylist as $key => $item) {
  echo "$key=$item; ";
}

Output: 2=b; 3=c; 1=a;

Array was processed in the "first added first processed" order, regardless key values.

Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC