Get the App
SLTechnology News&Howtos  ›  Development  › 

How php removes the last array element

Shulou Source: shulou.com Published: 2022-06-03 11:37:11 09月25日 Update

Editor to share with you how php removed the last array element, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

Php to remove the last array element method: 1, use array_pop () function, syntax "array_pop ($arr)"; 2, use array_splice () function, syntax "array_splice ($arr,-1)".

Operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer

Method 1: use the array_pop () function

The array_pop () function is used to delete the element at the end of the array.

Output result:

Method 2: use the array_splice () function

The array_splice () function is used to delete some elements of the array; set the second argument of the array_splice () function to-1 to delete the last array element.

Example:

Output result:

The above is all the content of the article "how to remove the last array element from php". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Functions elements arrays methods articles content results syntax output not much parameters most tutorials more endings environments computers knowledge examples systems Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Shulou Tech Info OPPO Reno Apple MariaDB