PHP array_pop Delete array last element instance _php instance

Source: Internet
Author: User
Tags php example

The PHP array_pop function pops the last cell of the array (out of the stack), which deletes the last element of the array. This article through the PHP example to explain the use of Array_pop function method.

array_pop-the last cell of the array (out of stack)

Description

Mixed Array_pop (array & $array)

Array_pop () pops up and returns the last cell of the array, minus one of the array lengths. If the array is empty (or not an array), it returns NULL. In addition, a Warning is generated if the call is not a number.

Note: the (reset ()) array pointer is reset when this function is used.

Parameter introduction

Parameters Description
Array Necessary. An array of stacks needs to be made.

return value

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

Instance:

<?php
 $stack = Array ("Orange", "banana", "apple", "raspberry");
 $fruit = Array_pop ($stack);
 Print_r ($stack);
? > 

After this operation, the $stack will have only 3 units:

Array
(
  [0] => Orange
  [1] => banana
  [2] => Apple
)



Thank you for reading, I hope to help you, thank you for your support for this site!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.