【发布时间】:2017-03-23 06:19:05
【问题描述】:
我的字符串如下所示:
Response: 311768560
311768562
311768564
我试过了:
$success_pattern="Response: ((\d+)[\n])*";
$response="Response: 311768560\n311768562\n311768564\n311768566";
preg_match("/$success_pattern/i", $response, $match);
输出:
Array (
[0] => Response: 311768560 311768562 311768564
[1] => 311768564
[2] => 311768564
)
我需要一个包含所有数字的数组作为输出,例如:
array('311768560','311768562','311768564');
【问题讨论】:
-
如你所愿,只需 preg_match 然后告诉我,是否固定会有 3 个数字?
标签: php regex preg-match-all numeric substring