Get the App
SLTechnology News&Howtos  ›  Development  › 

How to delete the last two elements of an array by php

Shulou Source: shulou.com Published: 2022-06-03 14:55:16 11月15日 Update

Xiaobian to share with you how to delete the last 2 elements of the array php, I believe most people still do not know how to share this article for your reference, I hope you have a lot of harvest after reading this article, let's go to understand it together!

The array_splice() function can be used to delete the last two elements of an array.

2. This function is used to delete the specified number of elements from the specified position. You only need to set the second parameter of the array_splice() function to "-2".

syntax

array_splice($arr,-2)

examples

The above is "php how to delete the array after 2 elements" all the content of this article, thank you for reading! I believe that everyone has a certain understanding, hope to share the content to help everyone, if you still want to learn more knowledge, welcome to pay attention to the industry information channel!

Tags: Elements arrays functions articles content not much location parameters most examples more purpose knowledge industry grammar information information channels channels references learning Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology Apple MySQL Redmi Docker