Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

question about array_push() function

Status
Not open for further replies.

jisoo23

Programmer
Joined
Jan 27, 2004
Messages
192
Location
US
Hello all,

I was wondering if anyone knew if the array_push() function also works for associative arrays? For example:
Code:
$myarray = Array();
array_push($key=>$value);

I've looked around and have only seen examples of regular, indexed arrays.

Thanks!
Jisoo23
 
If you need to preserve the key, you would be best off using array_merge() instead.

$tmpArray = array($var => $id);
$newArray = array_merge ($newArray, $tmpArray);

______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top