# How to use array shift in PHP

In this article, I will explain how the array_shift() function can be used in PHP.
• 1814

array_shift() function in PHP

• The array_shift() function is used to delete the first element from an array, and returns the value of the removed element.

• In array_shift() function, If the keys are numeric, all elements will get new keys, starting from 0 and increases by 1.

• In array_shift() function, All numerical array keys will be modified to start counting from zero.

Syntax

 array_shift(array)

Parameter

• array  array is required parameter. Specifies an array.

Example

The following example show to how the array_shift() function can be used in PHP.



array_shift() function example in PHP

'Student', 1=> 'Teacher', 2 => 'Advocate',3 => 'Engg.');      \$result= array_shift(\$list);      print_r(\$list);      echo '
Shift element :
'.\$result;      ?>

Output You may also want to read these related articles here
{"ft_lang_label":"__label__en","ft_lang_prob":0.6431009,"math_prob":0.69796336,"size":1026,"snap":"2020-34-2020-40","text_gpt3_token_len":250,"char_repetition_ratio":0.18395303,"word_repetition_ratio":0.062111802,"special_character_ratio":0.2748538,"punctuation_ratio":0.13541667,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.98166317,"pos_list":[0,1,2,3,4],"im_url_duplicate_count":[null,null,null,3,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-10-01T12:56:30Z\",\"WARC-Record-ID\":\"<urn:uuid:cb59be4b-4532-4702-b37d-643754e53337>\",\"Content-Length\":\"57805\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:5b346b85-0d8d-44f6-a29a-faf3693eddb0>\",\"WARC-Concurrent-To\":\"<urn:uuid:357d2826-69b6-45ee-aebd-7bcdbfa0df68>\",\"WARC-IP-Address\":\"104.27.145.103\",\"WARC-Target-URI\":\"https://www.dotnetheaven.com/article/how-to-use-array-shift-in-php\",\"WARC-Payload-Digest\":\"sha1:7GTL4JE7PK7AQJDZSGAFHJUO6OPE3FHU\",\"WARC-Block-Digest\":\"sha1:5NCHGKEGWAAGAYPF66TYCEE6NIDKKRGZ\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-40/CC-MAIN-2020-40_segments_1600402131412.93_warc_CC-MAIN-20201001112433-20201001142433-00651.warc.gz\"}"}