array_unshift
-
We can unshift elements off of the beginning of an array in Ruby using the
Array#unshiftmethod.PHP
$fruit = array('kiwi', 'lime'); array_unshift($fruit, 'apple', 'orange'); var_export($fruit); // => array(0 => 'apple', 1 => 'orange', 2 => 'kiwi', 3 => 'lime')
Ruby
fruit = ["kiwi", "lime"] fruit.unshift("apple", "orange") p fruit # => ["apple", "orange", "kiwi", "lime"]
see also
Looking for Rails or PHP web application development, integration, and training?
Rails for PHP is brought to you by Maintainable Software. Get custom web applications and personalized training from the authors of the book and website.

