📄 function.array-splice.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>Remove a portion of the array and replace it with something else</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-slice.html">array_slice</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.array-sum.html">array_sum</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-splice" class="refentry"> <div class="refnamediv"> <h1 class="refname">array_splice</h1> <p class="verinfo">(PHP 4, PHP 5)</p><p class="refpurpose"><span class="refname">array_splice</span> — <span class="dc-title">Remove a portion of the array and replace it with something else</span></p> </div> <div class="refsect1 description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">array</span> <span class="methodname"><b><b>array_splice</b></b></span> ( <span class="methodparam"><span class="type">array</span> <tt class="parameter reference">&$input</tt></span> , <span class="methodparam"><span class="type">int</span> <tt class="parameter">$offset</tt></span> [, <span class="methodparam"><span class="type">int</span> <tt class="parameter">$length</tt></span> [, <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <tt class="parameter">$replacement</tt></span> ]] )</div> <p class="para rdfs-comment"> Removes the elements designated by <i><tt class="parameter">offset</tt></i> and <i><tt class="parameter">length</tt></i> from the <i><tt class="parameter">input</tt></i> array, and replaces them with the elements of the <i><tt class="parameter">replacement</tt></i> array, if supplied. </p> <p class="para"> Note that numeric keys in <i><tt class="parameter">input</tt></i> are not preserved. </p> <blockquote><p><b class="note">Note</b>: <span class="simpara"> If <i><tt class="parameter">replacement</tt></i> is not an array, it will be <a href="language.types.array.html#language.types.array.casting" class="link">typecast</a> to one (i.e. <code class="code">(array) $parameter</code>). This may result in unexpected behavior when using an object <i><tt class="parameter">replacement</tt></i>. </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">input</tt></i></span> <dd> <p class="para"> The input array. </p> </dd> </dt> <dt> <span class="term"><i><tt class="parameter">offset</tt></i></span> <dd> <p class="para"> If <i><tt class="parameter">offset</tt></i> is positive then the start of removed portion is at that offset from the beginning of the <i><tt class="parameter">input</tt></i> array. If <i><tt class="parameter">offset</tt></i> is negative then it starts that far from the end of the <i><tt class="parameter">input</tt></i> array. </p> </dd> </dt> <dt> <span class="term"><i><tt class="parameter">length</tt></i></span> <dd> <p class="para"> If <i><tt class="parameter">length</tt></i> is omitted, removes everything from <i><tt class="parameter">offset</tt></i> to the end of the array. If <i><tt class="parameter">length</tt></i> is specified and is positive, then that many elements will be removed. If <i><tt class="parameter">length</tt></i>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -