aximbigfan Posted December 22, 2008 Share Posted December 22, 2008 Is there any way to determine where a key is added to an array? I need to be able to put some values at the beginning of the array, and some at the end of the array. Thanks Quote Link to comment Share on other sites More sharing options...
premiso Posted December 22, 2008 Share Posted December 22, 2008 array array_unshift — Prepend one or more elements to the beginning of an array array_push — Push one or more elements onto the end of array Quote Link to comment Share on other sites More sharing options...
redarrow Posted December 22, 2008 Share Posted December 22, 2008 array_unshift() and array_push(). <?php $stack = array("orange", "banana"); array_push($stack, "apple", "raspberry"); print_r($stack); ?> <?php $queue = array("orange", "banana"); array_unshift($queue, "apple", "raspberry"); print_r($queue); ?> Quote Link to comment Share on other sites More sharing options...
aximbigfan Posted December 22, 2008 Author Share Posted December 22, 2008 Great! Thanks! Chris Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.