array_unshift

The array_unshift() function in PHP prepends elements onto the beginning of an array.

PHP

$cue = array('http', 'https', 'ftp');
array_unshift($cue, 'ssh');
print_r($cue);
/*
Array (
	[0] => ssh
	[1] => http
	[2] => https
	[3] => ftp
)
*/

Ruby has an identical Array method, named unshift:

Ruby

cue = [ "http", "https", "ftp" ];
cue.unshift('ssh');
puts cue;
# => [ "ssh", "http", "https", "ftp"]
By | 2009-10-16T08:08:17+00:00 October 7th, 2009|Categories: PHP, Ruby|Tags: , , , |Comments Off on array_unshift

About the Author:

This Is A Custom Widget

This Sliding Bar can be switched on or off in theme options, and can take any widget you throw at it or even fill it with your custom HTML Code. Its perfect for grabbing the attention of your viewers. Choose between 1, 2, 3 or 4 columns, set the background color, widget divider color, activate transparency, a top border or fully disable it on desktop and mobile.

This Is A Custom Widget

This Sliding Bar can be switched on or off in theme options, and can take any widget you throw at it or even fill it with your custom HTML Code. Its perfect for grabbing the attention of your viewers. Choose between 1, 2, 3 or 4 columns, set the background color, widget divider color, activate transparency, a top border or fully disable it on desktop and mobile.