jberlinsky Posted September 6, 2006 Share Posted September 6, 2006 I have been TRYING to use preg_replace()...it doesnt give me the right resultOBJECTIVE: change <img src=BLAH alt=x> to <img src=BLAH alt=y>ATTEMPTED SYNTAX: $post['post'] = preg_replace("/<img src=[(.+?)] alt=x>/","<img src=\\1 alt-y>",$post['post']); Quote Link to comment Share on other sites More sharing options...
effigy Posted September 6, 2006 Share Posted September 6, 2006 [code]<pre><?php $string = '<img src=BLAH alt=x>'; echo preg_replace('/(<img src=(?:.+?) alt=)x>/', '\1y>', $string);?></pre>[/code] Quote Link to comment Share on other sites More sharing options...
Nicklas Posted September 6, 2006 Share Posted September 6, 2006 Or[code=php:0]preg_replace('/(<img.*?alt=).*?>/is', '\\1y>', $string);[/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.