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_pop

Trieda

Koreň \ Bez triedy

Metóda - array_pop

(PHP 4, PHP 5, PHP 7)

Removes the last element from an array. The function allows you to use the array as a queue, so it should only be used if we work with the array as a queue.

Numerical indexes will be renumbered from 0. The function resets the internal pointer to the current element in the array.

Procedurálne

Parametre

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

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

Mávratovej hodnoty

Vracia: mixed

The last element in the array. If the array is empty, the function returns NULL.

Príklady

<?php
$queue = ['Homer', 'Marge', 'Bart', 'Lisa', 'Meggie'];
$simpson = array_pop($queue);

print_r($queue);
echo $simpson;

It removes the last element 'Meggie' from the queue and saves it into the variable $simpson.

Súvisiace manuály

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