php function array_pop to delete the last element in the array

PHP中文网
Release: 2023-03-16 21:08:02
Original
1433 people have browsed it

php array_pop function pops (pops) the last unit of the array, that is, deletes the last element of the array. This article explains how to use the array_pop function through PHP examples.

array_pop — pop the last unit of the array (pop off the stack)

mixed array_pop (array &$array)

array_pop() pops and returns the array array last element and decrements the length of the array by one. NULL will be returned if array is empty (or not an array). In addition, a Warning will be generated if the called value is not a number.

Note: The array pointer will be reset (reset()) after using this function.

Delete the last element in the array:

<?php
$a=array("red","green","blue");
array_pop($a);
print_r($a);
?>
Copy after login

Definition and usage

array_pop() function deletes the last element in the array.

Syntax

array_pop(array)
Copy after login

Parameters Description

##array Required. Specifies an array.

//实例
//删除数组中的最后一个元素:
<?php
$a=array("red","green","blue");
array_pop($a);
print_r($a);
?>

运行实例 »
定义和用法
array_pop() 函数删除数组中的最后一个元素。
语法
array_pop(array)

参数描述
array    必需。规定数组。
Copy after login


The above is the detailed content of php function array_pop to delete the last element in the array. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template