php remove last element from array

藏色散人
Release: 2023-03-08 16:04:02
Original
2833 people have browsed it

php method to remove the last element of an array: first create a PHP sample file; then define an array; and finally delete the last element in the array through the "array_pop($test_arr)" method.

php remove last element from array

The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer

array_pop() function

Delete the last element in the array. Returns null if the array is empty.

Example:

<?php
$test_arr = array (
    "name" => "jeanphorn",
    "skill" => "programming",
    "hobby" => "swimming",
);
echo array_pop($test_arr). "\n";   
print_r($test_arr);
?>
Copy after login

[Recommended learning: "PHP Video Tutorial"]

The above is the detailed content of php remove last element from array. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
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