[英]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.