Home Backend Development PHP Tutorial How to delete the last element of an array?_PHP Tutorial

How to delete the last element of an array?_PHP Tutorial

Jul 13, 2016 pm 05:12 PM
array mix pop element function delete prototype how talent array at last use of this

Just use the array_pop function in PHP4. Function prototype:
mixed array_pop(array array)
For example:
<?
$array = array('PHP','JSP ','ASP');
$count = count($array);
echo 'old:<br>';
for($i=0;$i<$count;$i++ ) echo $array[$i].'<br>';
array_pop($array);
$count = count($array);
echo 'new:<br>';
for($i=0;$i<$count;$i++) echo $array[$i].'<br>';
?>
Output result:
old :
PHP
JSP
ASP
new:
PHP
JSP

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/629512.htmlTechArticleUse the array_pop function in PHP4. Function prototype: mixed array_pop(array array) For example: ? $array = array('PHP','JSP','ASP'); $count = count($array); echo 'old:br'; for(...
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

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to completely delete TikTok chat history How to completely delete TikTok chat history May 07, 2024 am 11:14 AM

How to completely delete TikTok chat history

Complete collection of excel function formulas Complete collection of excel function formulas May 07, 2024 pm 12:04 PM

Complete collection of excel function formulas

PHP array key value flipping: Comparative performance analysis of different methods PHP array key value flipping: Comparative performance analysis of different methods May 03, 2024 pm 09:03 PM

PHP array key value flipping: Comparative performance analysis of different methods

The Art of PHP Array Deep Copy: Using Different Methods to Achieve a Perfect Copy The Art of PHP Array Deep Copy: Using Different Methods to Achieve a Perfect Copy May 01, 2024 pm 12:30 PM

The Art of PHP Array Deep Copy: Using Different Methods to Achieve a Perfect Copy

The first Snapdragon 8 Gen3 small foldable! Xiaomi MIX Flip joins the Internet: 67W fast charging, super large secondary screen The first Snapdragon 8 Gen3 small foldable! Xiaomi MIX Flip joins the Internet: 67W fast charging, super large secondary screen May 31, 2024 pm 08:26 PM

The first Snapdragon 8 Gen3 small foldable! Xiaomi MIX Flip joins the Internet: 67W fast charging, super large secondary screen

Application of PHP array grouping function in data sorting Application of PHP array grouping function in data sorting May 04, 2024 pm 01:03 PM

Application of PHP array grouping function in data sorting

Best Practices for Deep Copying PHP Arrays: Discover Efficient Methods Best Practices for Deep Copying PHP Arrays: Discover Efficient Methods Apr 30, 2024 pm 03:42 PM

Best Practices for Deep Copying PHP Arrays: Discover Efficient Methods

The role of PHP array grouping function in finding duplicate elements The role of PHP array grouping function in finding duplicate elements May 05, 2024 am 09:21 AM

The role of PHP array grouping function in finding duplicate elements

See all articles