Here is a var_dump of a multidimensional array.
array (size=2)
'ad795f9b369fc967db8fe0611ecc3cb3' =>
array (size=6)
'rowid' => string 'ad795f9b369fc967db8fe0611ecc3cb3' (length=32)
'id' => string '101_89765' (length=9)
'qty' => string '1' (length=1)
'price' => string '19.00' (length=5)
'name' => string 'Product 2' (length=13)
'subtotal' => float 19
'19c452c64c3f308323dee72a8a4a4f62' =>
array (size=6)
'rowid' => string '19c452c64c3f308323dee72a8a4a4f62' (length=32)
'id' => string '114_54828' (length=9)
'qty' => string '1' (length=1)
'price' => string '452.25' (length=6)
'name' => string 'Product 1' (length=5)
'subtotal' => float 452.25
I need to flip the order so that it will display in the reverse product 1 before product 2. I tried using array_reverse before the foreach but it has no effect.
What else can I do? Thanks for the help! 🙂
array_reversedoes not accept it’s parameter by reference (as sort functions), instead it just returns the reversed array.So you should use
$array = array_reverse($array);