NOVINKA: Najžiadanejšie rekvalifikačné kurzy teraz s 50% zľavou + kurz AI ZADARMO. Nečakaj, táto ponuka dlho nevydrží! Zisti viac:

PHP - array_push

Trieda

Koreň \ Bez triedy

Metóda - array_push

(PHP 4, PHP 5, PHP 7)

Inserts an element into an array after the last element. The function allows you to use the array as a stack, so it should only be used if we work with the array as a stack.

Otherwise, we insert the last element using $array[] = $element; The function resets the internal pointer to the current element in the array.

Procedurálne

  • function array_push (array &$array, mixed $value1, mixed $...) : int

Parametre

NázovDátový typPredvolená hodnotaPopis
&$arrayarray

An array (stack). If the parameter is not the array, it throws a warning.

$value1mixed

An inserted element.

$...mixed

An additional element to insert.

Mávratovej hodnoty

Vracia: int

A new number of elements in the array.

Príklady

<?php
$stack= ['Homer', 'Marge', 'Bart', 'Lisa'];
array_push($stack, 'Meggie');

print_r($stack);

Súvisiace manuály

      Aktivity