如何在preg_match中显示匹配字符

时间:2016-10-17 00:49:16

标签: php preg-match

我想通过使用preg_match()将字符串匹配到正则表达式这是我的代码

<?php
$string = preg_match("/http\:\/\//","http");
echo $stirng;
?>

这很好用。但我想显示匹配的字符是什么。怎么做?

1 个答案:

答案 0 :(得分:0)

使用$匹配preg_match函数中的另一个参数。喜欢这个

<?php
preg_match("/http\:\/\//","http://",$matches);
// this $matches echo out as a array object then,
print_r($matches);
?>

我希望这会奏效。

相关问题