How php removes two values from an array
The knowledge of this article "php how to remove the two values of the array" is not quite understood by most people, so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "php how to remove the two values of the array" article.
Two methods to remove: 1, call the unset () function twice to delete the two elements, syntax "unset (array name [subscript / key name])"; 2, use the array_splice () function to delete two elements from the specified location of the array, syntax "array_splice ($arr, start position, 2)".
Operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
Two methods for php to remove two values of an array
Method 1: call the unset () function twice to delete two elements
The unset () function deletes a specified element
Syntax:
Unset (array name [subscript]); / / delete an element in the indexed array unset (array name ["key name"]); / / associate an element in the array
Example 1:
Example 2:
Method 2: use the array_splice () function
When the array_splice () function deletes some elements of an array, it combines those deleted elements into a new array.
Example 1: delete 2 elements of the array from the beginning
Example 2: delete 2 elements of the array after the first element
Example 3: delete 2 elements of the array after the second element
The above is the content of this article on "how to remove the two values of the array from php". I believe we all have some understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please follow the industry information channel.