Page 1 of 1

array_push.. wont accept ($key => "value")

Posted: Wed Jan 28, 2004 11:48 am
by bg
If you can define an array as such:

Code: Select all

$blah = array(0 => "value", 1 => "value2");
why cant you use array_push in a similar fashion, for example

Code: Select all

array_push($array, 0 => "value");
What is a good work around for this?

Posted: Wed Jan 28, 2004 11:53 am
by spaace
I think that its because array_push is acting like a stack, which will only allow the last-in-first-out order of the data. Otherwise, array_pop would not give you back the data in the reverse order it was pushed on.

By passing a key or index it will mess this order up.