Php $matches[0]未在屏幕上显示数据,但表示数据在屏幕上? $str=“
”; preg_match_all(“/]>/”,$str,$matches); My$matches[0]表示有数据(字符串长度43),但屏幕上没有字符串输出 数组(1){[0]=>string(43)“}Php $matches[0]未在屏幕上显示数据,但表示数据在屏幕上? $str=“,php,regex,preg-match,preg-match-all,Php,Regex,Preg Match,Preg Match All,”; preg_match_all(“/]>/”,$str,$matches); My$matches[0]表示有数据(字符串长度43),但屏幕上没有字符串输出 数组(1){[0]=>string(43)“} 如果我删除,您将无法在屏幕上获取数据,可能是因为浏览器试图呈现未知的html/xml标记: 使用您的代码,我在$matches上得到以下结果: $str = "<p><example:wow id='test' style='hello' /></p>
如果我删除
,您将无法在屏幕上获取数据,可能是因为浏览器试图呈现未知的html/xml标记:
使用您的代码,我在$matches上得到以下结果:
$str = "<p><example:wow id='test' style='hello' /></p>";
preg_match_all ("/<example:wow(.*)[^>]>/", $str, $matches);
您可能会将其输出到尖括号有意义的地方,例如网页,浏览器通常将其解释为html。然后使用查看源代码。@mario-谢谢你correct@user983223:作为一个旁白问题,您需要提取什么?
Array
(
[0] => Array
(
[0] => <example:wow id='test' style='hello' /></p>
)
[1] => Array
(
[0] => id='test' style='hello' /></
)
)
print_r ($matches);