★ wanayoo — archive 1999 http://php.net/manual/es/function.array-push.phpNouvelle recherche | Portail wanayoo

PHP Home Page

Manual Table of Contents
Up to Matrices
Quick Reference
Matrices
English version of this pageGerman version of this pageJapanese version of this page
Italian version of this pageFrench version of this pageHungarian version of this page
Spanish version of this page
* 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
* rango
* reset
* rsort
* shuffle
* sizeof
* sort
* uasort
* uksort
* usort

  Thanks to:
 Chek.com
 easyDNS
 VA Linux Systems

  Related sites:
Apache
MySQL
PostgreSQL
Zend Tech.

  Community:
LinuxFund.org
OSDN
Manual: array_push
View the source code for this pageSearch the site



Previous page
 array_pop
 Updated
Thu, 14 Sep 2000
array_reverse 
Next page


array_push

(PHP4 )

array_push --  Inserta uno o más elementos al final de la matriz

Descripción

int array_push (array matriz, mixed var [, ...])

array_push() considera a la matriz como una pila, e inserta las variables que se le pasan al final de la matriz. La longitud de la matriz se incrementa en el número de variables insertadas. Tiene el mismo efecto que ejecutar:

$matriz[] = $var;
     
para cada var.

Devuelve el nuevo número de elementos de la matriz.

Ejemplo 1. Ejemplo de array_push()


$pila = array (1, 2);
array_push($pila, "+", 3);
      
Este ejemplo dejará $pila conteniendo 4 elementos: 1, 2, "+", y 3.

Vea también: array_pop(), array_shift(), y array_unshift().

Nota: Esta función fue añadida en el PHP 4.0.


User Contributed Notes: array_push


swo@hpinc.com
12-Jan-2000 09:03
It's possible to delete an array (at least in php 3) using "unset ($arrayname);" (without the quotes).




sheppard_norfleet@mail.crc.com
08-Feb-2000 09:14
If you want to push a key value pair onto an associative array. This is the "correct" syntax.

Array[$Key] = AnotherArray;

Hope this helps somebody.



unnikrishnan@gocubs.com
02-Mar-2000 03:32
If you want to add a element to a linear table (one dimensional) the traditional method is best.
$array_name[]=$variable_name
On the other hand if you want to insert a
($key,$val)
into an array the easy way is
$array_name[$key]=$val
Thats all.



j.kase@privador.com
01-Jul-2000 01:38
I needed to use array_push with PHP3, and instead of array_push($array,$item) I used $array[count($array)] = $item, to add the last element. Works if you have number-based arrays (i.e elements are ordered).


 About Notes


Previous page
 array_pop
 Updated
Thu, 14 Sep 2000
array_reverse 
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.