Replacing a Pattern with a Found String : String Replace : String PHP Source Code


PHP Source Code » String » String Replace »

 

Replacing a Pattern with a Found String



<html>
<head>
<title>preg_replace</title>
</head>
<body>
<?php
     $string = "<a href="http://www.navioo.com/">navioo</a><br />";
   
     $pattern = '/<a.]*?(href *= *".*?").*?>(.*?)</a>/i';
     $replacement = '2<a 1>1</a>';
   
     $string = preg_replace($pattern, $replacement, $string);
     print($string);
?>
</body>
</html>

           
       



HTML code for linking to this page:

Follow Navioo On Twitter

PHP Source Code

 Navioo String
» String Replace