Home >Backend Development >PHP Tutorial >Detailed explanation of how to use PHP split() function_PHP tutorial

Detailed explanation of how to use PHP split() function_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-15 13:31:041523browse

Function prototype: array split (string $pattern, string $string [, int $limit])

PHP split() function returns a string array, each Each unit is a substring of $string divided by the regular expression $pattern as a boundary. If $limit is set, the returned array contains at most $limit cells. The last unit contains all the remaining parts of $string. spliti is a size-ignoring version of split. Listing 6.8 is an example that is often used with dates.

PHP split() function code 6.8 Date splitting

<ol class="dp-xml">
<li class="alt"><span><span class="tag"><</span><span> ?php   </span></span></li><li><span>$</span><span class="attribute">date</span><span> = </span><span class="attribute-value">"08/30/2006"</span><span>;  </span></li><li class="alt"><span>//分隔符可以是斜线,点,或横线  </span></li><li><span>list($month, $day, $year) = split <br />('[/.-]', $date);  </span></li><li class="alt"><span>//输出为另一种时间格式  </span></li><li><span>echo "Month: $month; Day: $day; Year: <br />$year</span><span class="tag">< </span><span class="tag-name">br</span><span> </span><span class="tag">/></span><span>n";  </span></span></li>
<li class="alt">
<span class="tag">?></span><span> </span>
</li>
</ol>

I hope that through the above code example of the PHP split() function, everyone can clearly understand the specific meaning of this function. .


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/446247.htmlTechArticleFunction prototype: array split (string $pattern, string $string [, int $limit]) PHP split() The function returns a string array, each cell is $string with the regular expression $pattern as the boundary...
Statement:
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