[英]PHP Regex match and split then catch all values in the same array
我有一些字符串值,例如
模式:n位数字,,,字
我想得到:
(1)
["30", "abcd efgh"]
(2)
["35", "xyz PQRS"]
(3)
["50", "DEF xyz"]
我怎样才能做到这一点?
为什么要加载整个正则表达式引擎,您可以使用explode()
$in = '30 abcd efgh';
$bits = explode(' ', $in, 2);
print_r($bits);
结果
Array
(
[0] => 30
[1] => abcd efgh
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.