【发布时间】:2010-12-12 16:48:23
【问题描述】:
preg_match() 给出一个匹配。preg_match_all() 返回所有匹配。preg_split() 返回所有拆分。
我怎样才能只在第一场比赛中分裂?
例子:
preg_split("~\n~", $string);
这就是我想要的:
array(
0 => 'first piece',
1 => 'the rest of the string
without any further splits'
)
【问题讨论】:
-
如果你只是使用 \n 分割成一个数组,你可以使用explode。它比 preg_split 稍快。
标签: php arrays split explode preg-split