⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 function.spliti.html

📁 php的帮助文档,涉及到PHP的案例和基本语法,以及实际应用内容
💻 HTML
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head>  <title>Split string into array by regular expression case insensitive</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.split.html">split</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.sql-regcase.html">sql_regcase</a></div> <div class="up"><a href="ref.regex.html">POSIX Regex Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="function.spliti" class="refentry"> <div class="refnamediv">  <h1 class="refname">spliti</h1>  <p class="verinfo">(PHP 4 &gt;= 4.0.1, PHP 5)</p><p class="refpurpose"><span class="refname">spliti</span> &mdash; <span class="dc-title">Split string into array by regular expression case insensitive</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>spliti</b></b></span>    ( <span class="methodparam"><span class="type">string</span> <tt class="parameter">$pattern</tt></span>   , <span class="methodparam"><span class="type">string</span> <tt class="parameter">$string</tt></span>   [, <span class="methodparam"><span class="type">int</span> <tt class="parameter">$limit</tt></span>  ] )</div>  <p class="para rdfs-comment">   Splits a <i><tt class="parameter">string</tt></i> into array by regular expression.  </p>  <p class="para">   This function is identical to <a href="function.split.html" class="function">split()</a> except that this   ignores case distinction when matching alphabetic characters.  </p> </div> <div class="refsect1 parameters">  <h3 class="title">Parameters</h3>  <p class="para">   <dl>    <dt>     <span class="term"><i><tt class="parameter">pattern</tt></i></span>     <dd>      <p class="para">       Case insensitive regular expression.      </p>      <p class="para">       If you want to split on any of the characters which are considered       special by regular expressions, you&#039;ll need to escape them first. If       you think <b>spliti()</b> (or any other regex function, for       that matter) is doing something weird, please read the file       <var class="filename">regex.7</var>, included in the        <var class="filename">regex/</var> subdirectory of the PHP distribution. It&#039;s       in manpage format, so you&#039;ll want to do something along the lines of       <strong class="command">man /usr/local/src/regex/regex.7</strong> in order to read it.      </p>     </dd>    </dt>    <dt>     <span class="term"><i><tt class="parameter">string</tt></i></span>     <dd>      <p class="para">       The input string.      </p>     </dd>    </dt>    <dt>     <span class="term"><i><tt class="parameter">limit</tt></i></span>     <dd>      <p class="para">       If <i><tt class="parameter">limit</tt></i> is set, the returned array will       contain a maximum of <i><tt class="parameter">limit</tt></i> elements with the       last element containing the whole rest of       <i><tt class="parameter">string</tt></i>.      </p>     </dd>    </dt>   </dl>  </p> </div> <div class="refsect1 returnvalues">  <h3 class="title">Return Values</h3>  <p class="para">   Returns an array of strings, each of which is a substring of   <i><tt class="parameter">string</tt></i> formed by splitting it on boundaries formed   by the case insensitive regular expression <i><tt class="parameter">pattern</tt></i>.  </p>  <p class="para">   If there are <span class="replaceable">n</span> occurrences of   <i><tt class="parameter">pattern</tt></i>, the returned array will contain   <i><span class="replaceable">n</span>+1</i> items. For example, if   there is no occurrence of <i><tt class="parameter">pattern</tt></i>, an array with   only one element will be returned. Of course, this is also true if   <i><tt class="parameter">string</tt></i> is empty. If an error occurs,   <b>spliti()</b> returns <b><tt>FALSE</tt></b>.  </p> </div> <div class="refsect1 examples">  <h3 class="title">Examples</h3>  <p class="para">   This example splits a string using &#039;a&#039; as the separator :   <div class="example">    <p><b>Example #1 <b>spliti()</b> example</b></p>    <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$string&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"aBBBaCCCADDDaEEEaGGGA"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$chunks&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">spliti&nbsp;</span><span style="color: #007700">(</span><span style="color: #DD0000">"a"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$string</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">5</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$chunks</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>    </div>    <div class="example-contents"><p>The above example will output:</p></div>    <div class="example-contents"><pre><div class="cdata"><pre>Array(  [0] =&gt;  [1] =&gt; BBB  [2] =&gt; CCC  [3] =&gt; DDD  [4] =&gt; EEEaGGGA)</pre></div>    </pre></div>   </div>  </p> </div> <div class="refsect1 seealso">  <h3 class="title">See Also</h3>  <p class="para">   <ul class="simplelist">    <li class="member"><a href="function.preg-split.html" class="function" rel="rdfs-seeAlso">preg_split()</a></li>    <li class="member"><a href="function.split.html" class="function" rel="rdfs-seeAlso">split()</a></li>    <li class="member"><a href="function.explode.html" class="function" rel="rdfs-seeAlso">explode()</a></li>    <li class="member"><a href="function.implode.html" class="function" rel="rdfs-seeAlso">implode()</a></li>   </ul>  </p> </div></div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.split.html">split</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.sql-regcase.html">sql_regcase</a></div> <div class="up"><a href="ref.regex.html">POSIX Regex 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 + -