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

PHP Home Page

Manual Table of Contents
Up to Tableaux
Quick Reference
English version of this pageGerman version of this pageJapanese version of this pageItalian version of this pageHungarian version of this page
Tableaux
* 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_shift
View the source code for this pageSearch the site



Previous page
 array_reverse
 Updated
Sun, 06 Aug 2000
array_slice 
Next page


array_shift

(PHP4 )

array_shift --  Dépile un élément au début d'un tableau

Description

mixed array_shift (array array)

array_shift() extrait la première valeur d'un tableau et la retourne, en raccourcissant le tableau d'un élément, et en déplacant tous les éléments vers le bas.

Exemple 1. Exemple avec array_shift()


$args = array ("-v", "-f");
$opt = array_shift ($args);
      
Cet exemple aura pour résultat que $args ne contiendra plus que "-f", et $opt contient "-v".

Voir aussi array_unshift(), array_push(), et array_pop().

Note: Cette fonction a été ajoutée dans PHP 4.0.


User Contributed Notes: array_shift


ernie@ernie.org
11-Mar-2000 12:37
I assume you mean php3.. I'd like to know how as well. Maybe something like:
<pre>
$value_from_beginning=$array[0];
for($i=0;$array[$i];$i++) {
$array[$i]=$array[$i+1];
}
unset( $array[$i] );
</pre>
hey, that seems to work! I just made that up on the spot 8)



raedward@vt.edu
13-Apr-2000 01:54
But I don't think this will shorten the array, there will simply be a null element at the end. Sizeof() would still return the original number of elements in the array, right? Is there a way in 3.0 to resize an array?


dmelomed@home.com
24-Jul-2000 10:49
Here's how according to bsilva@umesd.k12.or.us:

$temp = $arr["first_key"];
for (reset($arr), next($arr); $key=key($arr); next($arr)) {
$arr2[$key]=$arr[$key];




 About Notes


Previous page
 array_reverse
 Updated
Sun, 06 Aug 2000
array_slice 
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.