Does php conserve order in associative array? [duplicate]
Possible Duplicate: Are PHP Associative Arrays ordered? If I add items to associative array with different keys, does order of addition conserved? How can I access "previous" and "next" elements of given element? Yes, php arrays have an implicit order. Use reset , next , prev and current - or just a foreach loop - to inspect it. Yes, it does preserve the order. you can think of php arrays as ordered hash maps . You can think of the elements as being ordered by "index creation time". For example $a = array(); $a['x'] = 1; $a['y'] = 1; var_dump($a); // x, y $a = array(); $a['x'] = 1; $a['y'] = 1