★ wanayoo — archive 1999 http://www.php.net/manual/it/function.array-pop.phpNouvelle recherche | Portail wanayoo

PHP Home Page

Manual Table of Contents
Up to Arrays
Quick Reference
English version of this pageGerman version of this pageJapanese version of this pageFrench version of this pageHungarian version of this page
Arrays
* array
* array_count_values
* array_flip
* array_keys
* array_merge
* array_pad
* array_pop
* array_push
* array_reverse
* array_shift
* array_slice
* array_splice
* array_unshift
* array_values
* array_walk
* arsort
* asort
* compact
* count
* current
* each
* end
* extract
* in_array
* key
* krsort
* ksort
* list
* next
* pos
* prev
* range
* reset
* rsort
* shuffle
* sizeof
* sort
* uasort
* uksort
* usort
Manual: array_pop
View the source code for this pageSearch the site



Previous page
 array_pad
 Updated
Sun, 06 Aug 2000
array_push 
Next page


array_pop

(PHP4 )

array_pop -- Pop the element off the end of array

Description

mixed array_pop (array array)

array_pop() pops and returns the last value of the array, shortening the array by one element.

Esempio 1. array_pop() example


$stack = array ("orange", "apple", "raspberry");
$fruit = array_pop ($stack);
      

After this, $stack has only 2 elements: "orange" and "apple", and $fruit has "raspberry".

See also array_push(), array_shift(), and array_unshift().

Nota: This function was added in PHP 4.0.


User Contributed Notes: array_pop


ronny.engen@stud.hibo.no
02-May-2000 03:19
I don't know if it is a bug, or if it is me who doesn't use this correctly.
I have a range of number separated with
semicolon that comes is as a string-argument ($numbers).

<pre>
$isbn_exploded = explode(";", $numbers);
$isbn_exploded = rsort($isbn_exploded);
$counter = count($isbn_exploded);
for ($trv = $counter-1; $trv > -1; $trv--)
{
if ($isbn_exploded[$trv] < 1)
{
$temp_catch = array_pop($isbn_exploded);
}
}
</pre>

But I get told
Warning: The argument needs to be an array.

Explode returns an array, and the rsort just sort it. Why am I told that my sweet variable isn't what it's suppose to be?! Anyone!?



 About Notes


Previous page
 array_pad
 Updated
Sun, 06 Aug 2000
array_push 
Next page





Who's responsible for this?
Top of this page

Site
Hosting:



Located in
United States
Elements of this website are subject to copyright.
Questions about installing or using PHP should be directed to one of the mailing lists.
Only questions about the website should be directed to webmaster@php.net.