How to use array_shift() Function in PHP

array_shift function is used to shift or remove the first value of an array.

Here’s an example :

Output will look like this :

Array ( [0] => The Doors [1] => Dire Straits [2] => Simon and Garfunkel )

The first value from the array is removed. You can assign the removed value to a new variable like this :

$NewVariable = array_shift($bands);

This variable contains values from the array except the one you removed using the function.

Sharing is Caring
Imtiaz Rayhan

WordPress Enthusiast, Novice PHP Developer. Music Addict, The Beatles Fan. Conncect with me on Facebook, Google+ and Twitter.

Click Here to Leave a Comment Below 0 comments

Leave a Reply: