Switch to full style
:read: Start PHP with us. Includes topics to help you in php
Post a reply

Replacing a Pattern with a Found String

Sun Oct 26, 2008 10:20 pm

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




Post a reply
  Related Posts  to : Replacing a Pattern with a Found String
 Splitting a String Based on a Found String     -  
 replacing each tab by the string “Tab”,     -  
 Where is the value S_CONTENT_DIRECTION found?     -  
 DAO Pattern     -  
 Strategy Pattern     -  
 Factory pattern     -  
 DAO design pattern     -  
 about dao design pattern     -  
 The Singleton Pattern     -  
 Singleton Pattern Demo     -  

Topic Tags

PHP Strings