kidrobot2008 Posted August 10, 2008 Share Posted August 10, 2008 I need help converting the following working statement so it uses preg_replace instead. $text = "I love PHP Freaks."; $text = ' '. $text .' '; $words = "PHP Freaks"; $link = "<a href=http://www.phpfreaks.com>PHP Freaks</a>"; $text = eregi_replace("([ ,\.\?!:\(\)\r\n\<\>])". preg_quote($words) ."([ ,\.\?!:\(\)\r\n\<\>])", "\\1". ($link) ."\\2", $text); In the real deal $text is a paragraph of text and $words is a name. Thanks in advance. K Quote Link to comment Share on other sites More sharing options...
effigy Posted August 11, 2008 Share Posted August 11, 2008 $text = preg_replace('/\b'. preg_quote($words) . '\b/', $link, $text); 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.