Home > Backend Development > PHP Tutorial > Interpret the specific usage of PHP function explode()_PHP tutorial

Interpret the specific usage of PHP function explode()_PHP tutorial

WBOY
Release: 2016-07-15 13:30:17
Original
847 people have browsed it

CurrentlyPHP function explode() splits a string into an array
explode(separator,string,limit)
separator is required. Specifies where to split the string.
string required. The string to split.
limit optional. Specifies the maximum number of array elements returned.

PHP function explode() example

<ol class="dp-xml"><li class="alt"><span><span class="tag"><?</span><span class="tag-name">php</span><span> </span></span></li><li><span>$</span><span class="attribute">str</span><span> = </span><span class="attribute-value">"Hello world. It's a beautiful day."</span><span>;  </span></li><li class="alt"><span>print_r (explode(" ",$str));  </span></li><li><span class="tag">?></span><span> </span></span></li></ol>
Copy after login

Output:

<ol class="dp-xml">
<li class="alt"><span><span>Array  </span></span></li>
<li><span>(  </span></li>
<li class="alt">
<span>[0] =</span><span class="tag">></span><span> Hello  </span>
</li>
<li>
<span>[1] =</span><span class="tag">></span><span> world.  </span>
</li>
<li class="alt">
<span>[2] =</span><span class="tag">></span><span> It's  </span>
</li>
<li>
<span>[3] =</span><span class="tag">></span><span> a  </span>
</li>
<li class="alt">
<span>[4] =</span><span class="tag">></span><span> beautiful  </span>
</li>
<li>
<span>[5] =</span><span class="tag">></span><span> day.  </span>
</li>
<li class="alt"><span>) </span></li>
</ol>
Copy after login

The above code example is the specific use of PHP function explode() .


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/446303.htmlTechArticleCurrently, the PHP function explode() splits a string into an array explode(separator, string, limit) separator is required. Specifies where to split the string. string required. The string to split. l...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template