DeanWhitehouse Posted July 18, 2008 Share Posted July 18, 2008 <?php $oldstring = "[url=bob.php]bob[/url]"; $oldstring = eregi_replace("\[url=([^\[]+)\]([^\[]+)\][/url\]","<a href=\"\\1\" target=\"_blank\">\\2</a>", $oldstring); echo $oldstring; ?> this code is not doing anything, i don't know why it doesnt work, when i echo it it just says bob, anyone any ideas or can someone convert to preg_replace if need be? Quote Link to comment Share on other sites More sharing options...
effigy Posted July 18, 2008 Share Posted July 18, 2008 <pre> <?php $oldstring = '[url=bob.php]bob[/url]'; echo $oldstring = preg_replace( '%\[url=([^\]]+)\]([^\[]+)\[/url\]%', '<a href="$1" target="_blank">$2</a>', $oldstring ); ?> </pre> Quote Link to comment Share on other sites More sharing options...
DeanWhitehouse Posted July 18, 2008 Author Share Posted July 18, 2008 thanks, but i have just got it working ,there was an error in it. this is the code $code = eregi_replace("\+)\]([^\[]+)\[/url\]","<a href=\"\\1\" target=\"_blank\">\\2</a>",$code); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.