S.Macualiff S.Macualiff - 1 year ago 117
PHP Question

how to display matches characters in preg_match

I'd like to string matching with regular expression by using preg_match() This is my code

$string = preg_match("/http\:\/\//","http");
echo $stirng;

That is working well. But i want to display that what is the matching characters. how to do that?

Answer Source

Use $matches another parameter inside the preg_match function. Like this

// this $matches echo out as a array object then,

I hope this will work.