Home >Web Front-end >HTML Tutorial >Detailed introduction to array_shift

Detailed introduction to array_shift

零下一度
零下一度Original
2017-06-10 09:45:444711browse

What is the function of php array_shift() function? The array_shift() function in php deletes the first element in the array and returns the value of the deleted element. This article introduces the usage and definition of the php array_shift() function in detail. If you are interested, you can take a look. I hope it will be helpful to everyone. Definition and Usage The array_shift() function deletes the first element in the array and returns the value of the deleted element, or NULL if the array is empty. . If the key name is numeric, all elements will get new key names, starting from 0 and incrementing by 1 (refer to the code in Example 2 below), and the literal key values ​​will remain unchanged. Syntax array_shift(array) parameter array is the specified array and must be specified. Example 1 uses the php array_shift() function to delete the first element in the $stack array and return the deleted element.

1. Detailed explanation of php array_shift() function: delete the first element in the array

Detailed introduction to array_shift

Introduction: What is the role of php array_shift() function? The array_shift() function in php deletes the first element in the array and returns the value of the deleted element. This article introduces the usage and definition of the php array_shift() function in detail. If you are interested, you can take a look. I hope it will be helpful to everyone.

2. Detailed explanation of usage examples of array_push(), array_pop() and array_shift() functions in php

Detailed introduction to array_shift

Introduction: The php array_push function adds one or more elements (push) to the end of the array of the first parameter, and then returns the length of the new array. The array_pop() function removes the last element from an array. The array_shift() function deletes the first element in the array and returns the value of the deleted element. This article will introduce these three functions to you respectively, hoping to help you learn array functions.

3. Example analysis of commonly used array processing methods in PHP_PHP tutorial

Introduction: Commonly used array processing in PHP Method example analysis. 1.array_shift() moves the first unit of the array out and then returns it. This is very convenient for sometimes the first unit of the array needs to be processed separately. Copy the code as follows: ? $tmparray = array("1",

4. Introduction to the usage of PHP function array_shift() in deleting array elements_PHP Tutorial

##Introduction: Introduction to the use of the PHP function array_shift() in deleting array elements. In our previous article, we have described the function array_pop that deletes array elements at the end of the array. The specific usage of (), what we introduce to you today is to delete the number at the beginning of the array

5. php-Arrays function-array_shift-remove one at the beginning of the array Unit_PHP Tutorial

Introduction: php-Arrays function-array_shift-removes a unit at the beginning of the array array_shift() removes a unit at the beginning of the array [Function] This. The function will pop up and return the first unit of the array array, and then reduce the length of the array by one. All numeric key names will be changed from

[Related Q&A recommendations]:

javascript - Why should we use methods like [].shift.call(array) to implement array.shift()

The above is the detailed content of Detailed introduction to array_shift. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn