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. .