search
HomeBackend DevelopmentPHP ProblemHow to use array_pop function in php

Usage of array_pop function in php: [array_pop(array)]. The array_pop function is used to delete the last element in the array and return the last value in the array; if the array is empty or not an array, it returns null.

How to use array_pop function in php

php The array_pop function is used to delete the last element in the array. Its syntax is array_pop(array). The parameter array is required and specifies the array.

(Recommended tutorial: php video tutorial)

How to use the php array_pop function?

Function: Delete the last element in the array

Syntax:

array_pop(array)

Parameters:

array required. Specifies an array.

Description:

Returns the last value of the array. If the array is empty, or not an array, NULL will be returned.

php array_pop() function usage example 1

<?php
$a=array("西门","灭绝");
print_r(array_pop($a)); // 打印被删除的元素
echo "<br>";
print_r($a);  //打印处理之后的数组
?>

Output:

灭绝
Array ( [0] => 西门 )

php array_pop() function usage example 2

<?php
$a=array("无忌","欧阳克","peter_zhu");
print_r(array_pop($a)); // 打印被删除的元素
echo "<br>";
print_r($a);  //打印处理之后的数组
?>

Output:

peter_zhu
Array ( [0] => 无忌 [1] => 欧阳克 )

The above is the detailed content of How to use array_pop function in php. 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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools