![]() |
|
|
+ Search |
![]()
|
Jul 9th, 2003 12:34
Gerhardt, Andrew McFague,
<?php $text = "Some link: [URL=http://www.example.com/]Link[/URL]"; /* You didn't say if the link-description could contain square-brackets like "[". So I had to make it relativly general */ $pattern = '#\[URL\s*=\s*(\w+://[^\]]+)\](.+?)\[/URL]#'; $replacement = '<a href="\1">\2</a>'; $text = preg_replace($pattern,$replacement,$text); echo $text; ?>