📄 function.array-pop.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>Pop the element off the end of array</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.array-pad.html">array_pad</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.array-product.html">array_product</a></div> <div class="up"><a href="ref.array.html">Array Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="function.array-pop" class="refentry"> <div class="refnamediv"> <h1 class="refname">array_pop</h1> <p class="verinfo">(PHP 4, PHP 5)</p><p class="refpurpose"><span class="refname">array_pop</span> — <span class="dc-title">Pop the element off the end of array</span></p> </div> <div class="refsect1 description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <span class="methodname"><b><b>array_pop</b></b></span> ( <span class="methodparam"><span class="type">array</span> <tt class="parameter reference">&$array</tt></span> )</div> <p class="para rdfs-comment"> <b>array_pop()</b> pops and returns the last value of the <i><tt class="parameter">array</tt></i>, shortening the <i><tt class="parameter">array</tt></i> by one element. If <i><tt class="parameter">array</tt></i> is empty (or is not an array), <b><tt>NULL</tt></b> will be returned. Will additionally produce a <a href="errorfunc.constants.html#errorfunc.constants.errorlevels.e-warning" class="link">Warning</a> when called on a non-array. </p> <blockquote><p><b class="note">Note</b>: <span class="simpara">This function will <a href="function.reset.html" class="function">reset()</a> the <a href="language.types.array.html" class="type array">array</a> pointer after use.</span></p></blockquote> </div> <div class="refsect1 parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><i><tt class="parameter">array</tt></i></span> <dd> <p class="para"> The array to get the value from. </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns the last value of <i><tt class="parameter">array</tt></i>. If <i><tt class="parameter">array</tt></i> is empty (or is not an array), <b><tt>NULL</tt></b> will be returned. </p> </div> <div class="refsect1 examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example"> <p><b>Example #1 <b>array_pop()</b> example</b></p> <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB"><?php<br />$stack </span><span style="color: #007700">= array(</span><span style="color: #DD0000">"orange"</span><span style="color: #007700">, </span><span style="color: #DD0000">"banana"</span><span style="color: #007700">, </span><span style="color: #DD0000">"apple"</span><span style="color: #007700">, </span><span style="color: #DD0000">"raspberry"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$fruit </span><span style="color: #007700">= </span><span style="color: #0000BB">array_pop</span><span style="color: #007700">(</span><span style="color: #0000BB">$stack</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$stack</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?></span></span></code></div> </div> <div class="example-contents"><p> After this, <var class="varname">$stack</var> will have only 3 elements: </p></div> <div class="example-contents"><pre><div class="cdata"><pre>Array( [0] => orange [1] => banana [2] => apple)</pre></div> </pre></div> <div class="example-contents"><p> and <i>raspberry</i> will be assigned to <var class="varname">$fruit</var>. </p></div> </div> </p> </div> <div class="refsect1 seealso"> <h3 class="title">See Also</h3> <p class="para"> See also <a href="function.array-push.html" class="function" rel="rdfs-seeAlso">array_push()</a>, <a href="function.array-shift.html" class="function" rel="rdfs-seeAlso">array_shift()</a>, and <a href="function.array-unshift.html" class="function" rel="rdfs-seeAlso">array_unshift()</a>. </p> </div></div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.array-pad.html">array_pad</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.array-product.html">array_product</a></div> <div class="up"><a href="ref.array.html">Array Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -