Home > Backend Development > PHP Problem > How to remove the last string from an array in php

How to remove the last string from an array in php

藏色散人
Release: 2023-03-09 08:32:02
Original
1795 people have browsed it

php method to remove the last string of an array: first create a PHP sample file; then define an array; finally remove the last string of the array through the "array_pop($user);" method.

How to remove the last string from an array in php

The operating environment of this article: Windows 7 system, PHP version 7.1, DELL G3 computer

Use array_pop to delete the last element of the array, for example:

$user=array('apple','banana','orange');
$result=array_pop($user);
print_r($result);
print_r($user);
Copy after login

The result will be:

orange
array('apple','banana')
Copy after login

[Recommended learning: PHP video tutorial]

The above is the detailed content of How to remove the last string from an array in php. 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