Taylor York wrote:

Lets say im trying to replace every occurance of 'hello' with '<b>hi</b>'.

Here's something that's probably close to what you want. Something else you need to worry about besides <img> tags is what if the word "hello" appears in a <a> tag? within Javascript?


This will match anything outside of tags, at least, and then add in the <strong> tags around "hello".

function callback($match)
{ return str_replace('hello','<strong>hello</strong>',$match[0]); }

$new_str = preg_replace_callback('/>([^<]+)</','callback',$str);

--
---John Holmes...

Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to