0
 <?php
  $pattern = "/http:\\/\\/(([A-Za-z0-9.\-])*)/";
  $text = "http://www.google.com";
  $text = preg_replace($pattern,"<a href=\"\\0\">\\0</a>",$text);
  echo $text;
 ?>

The code above gets the URL from a string variable and adds an HTML tag for a link. So "http://www.google.com" becomes "<a href="http://www.google.com">http://www.google.com</a>". My question is how "\0" is something like placeholder for the value of the parameter "$text" in the "preg_repace" function, after it means NULL or 0x0?

PetarZ
  • 1

0 Answers0