(PHP 4 >= 4.0.1, PHP 5)
spliti — 锟斤拷锟斤拷锟斤拷锟斤拷式锟斤拷锟斤拷锟街达拷小写锟斤拷锟街凤拷锟斤拷锟街割到锟斤拷锟斤拷锟斤拷
$pattern
, string $string
[, int $limit
= -1
] ) : array
锟斤拷锟斤拷锟斤拷锟斤拷式锟斤拷一锟斤拷 string
锟街革拷锟斤拷锟斤拷椤�
锟斤拷锟斤拷锟斤拷锟斤拷 split() 锟斤拷同锟斤拷只锟斤拷锟斤拷锟斤拷匹锟斤拷锟斤拷母锟街凤拷时锟斤拷锟皆达拷小写锟斤拷锟斤拷锟斤拷
锟斤拷 PHP 5.3.0 锟斤拷锟窖撅拷锟斤拷锟斤拷锟剿猴拷锟斤拷锟斤拷强锟揭斤拷锟介不要应锟矫此猴拷锟斤拷 锟斤拷
pattern
锟斤拷小写锟斤拷锟斤拷锟叫碉拷锟斤拷锟斤拷锟斤拷式锟斤拷
If you want to split on any of the characters which are considered special by regular expressions, you'll need to escape them first. If you think spliti() (or any other regex function, for that matter) is doing something weird, please read the file regex.7, included in the regex/ subdirectory of the PHP distribution. It's in manpage format, so you'll want to do something along the lines of man /usr/local/src/regex/regex.7 in order to read it.
string
锟斤拷锟斤拷锟斤拷址锟斤拷锟�
limit
锟斤拷锟斤拷锟斤拷锟斤拷锟� limit
锟斤拷锟斤拷锟截碉拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟� limit
锟斤拷元锟截o拷锟斤拷锟揭伙拷锟皆拷匕锟斤拷锟斤拷锟绞o拷碌锟饺拷锟� string
锟斤拷
Returns an array of strings, each of which is a substring of
string
formed by splitting it on boundaries formed
by the case insensitive regular expression pattern
.
If there are n occurrences of
pattern
, the returned array will contain
n+1 items. For example, if
there is no occurrence of pattern
, an array with
only one element will be returned. Of course, this is also true if
string
is empty. If an error occurs,
spliti() returns FALSE
.
锟斤拷锟斤拷锟斤拷 'a' 锟斤拷锟街革拷锟斤拷锟斤拷锟街革拷一锟斤拷锟街凤拷锟斤拷锟斤拷
Example #1 spliti() 锟斤拷锟斤拷
<?php
$string = "aBBBaCCCADDDaEEEaGGGA";
$chunks = spliti ("a", $string, 5);
print_r($chunks);
?>
锟斤拷锟斤拷锟斤拷锟教伙拷锟斤拷锟斤拷锟�
Array ( [0] => [1] => BBB [2] => CCC [3] => DDD [4] => EEEaGGGA )
Note:
锟斤拷 PHP 5.3.0 锟叫o拷锟窖凤拷锟斤拷使锟斤拷 regex 锟斤拷展锟斤拷锟斤拷锟斤拷使锟斤拷 PCRE 锟斤拷展锟斤拷锟斤拷锟矫此猴拷锟斤拷锟斤拷锟结发锟斤拷
E_DEPRECATED
通知锟斤拷锟轿硷拷"锟斤拷锟斤拷锟叫憋拷"锟缴帮拷锟斤拷锟斤拷转为使锟斤拷 PCRE锟斤拷