Current Location: Home> Function Categories> array_pop

array_pop

Pop up the last unit of the array (out of the stack)
Name:array_pop
Category:Array
Programming Language:php
One-line Description:Delete the last element of the array (out of the stack).

Example

Delete the last element in the array

 <span class="token php language-php"><span class="token delimiter important"><?php</span>
<span class="token variable">$a</span> <span class="token operator">=</span> <span class="token keyword">array</span> <span class="token punctuation">(</span> <span class="token string double-quoted-string">"red"</span> <span class="token punctuation">,</span> <span class="token string double-quoted-string">"green"</span> <span class="token punctuation">,</span> <span class="token string double-quoted-string">"blue"</span> <span class="token punctuation">)</span> <span class="token punctuation">;</span>
<span class="token function"></span></span><mark><span class="token function">array_pop</span> <span class="token punctuation">(</span> <span class="token variable">$a</span> <span class="token punctuation">)</span></mark><span class="token punctuation"></span> <span class="token punctuation">;</span>
<span class="token function">print_r</span> <span class="token punctuation">(</span> <span class="token variable">$a</span> <span class="token punctuation">)</span> <span class="token punctuation">;</span>
<span class="token delimiter important">?></span>

Try it yourself

Similar Functions
  • Use user-defined functions to make callbacks to each element in the array array_walk

    array_walk

    Useuser-definedfunct
  • Point the inner pointer of the array to the last unit end

    end

    Pointtheinnerpointer
  • Sort arrays using the "natural sort" algorithm natsort

    natsort

    Sortarraysusingthe&q
  • Calculate the number of units in an array, or the number of attributes in an object count

    count

    Calculatethenumberof
  • Fill the array with the given value array_fill

    array_fill

    Fillthearraywiththeg
  • Create an array including variable names and their values compact

    compact

    Createanarrayincludi
  • Replace elements of the first array with the passed array array_replace

    array_replace

    Replaceelementsofthe
  • Use user-defined comparison functions to sort key names in an array uksort

    uksort

    Useuser-definedcompa
Popular Articles