【发布时间】:2016-07-06 13:35:26
【问题描述】:
我有以下字符串,例如:'Hello [owner], we could not contact by phone [phone], it is correct?'。
Regex 想以数组的形式返回,所有在[] 内。括号内只能是字母字符。
返回:
$array = [
0 => '[owner]',
1 => '[phone]'
];
我应该如何继续在 php 中返回这个?
【问题讨论】:
-
你标记了这个问题
preg-match-all——该函数的文档有有用的例子。你试过了吗?
标签: php regex preg-match preg-match-all