Page is a not externally linkable
- Code, Content, and Presentation
-- PHP Server Side Scripting
---- need help with preg replace


darkage - 2:33 pm on Dec 26, 2008 (gmt 0)


I've got articles that contain certain words I'd like to replace with links.

These words are between <p></p> tags. The word is identified by having a space in front of it and after it. I only want to replace the word with the link.

This is what I have done so far (the test word is hello), but it doesn't work:

Code:

$patterns[0] = "/<p>.+\s(hello)\s.+<\/p>/i";
$replacements[0] = "AAA"; // for testing
$pageContent = preg_replace($patterns, $replacements, $pageContent);

Thanks in advance.


Thread source:: http://www.webmasterworld.com/php/3814557.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com