play_ Posted May 13, 2007 Share Posted May 13, 2007 I'd like to do a preg_replace $text = 'Johnny said "hi suzie"'; $tag = '<span style="color: red">"'; $pattern = '"' // double quotes i'd like to replace the doublequotes in $text with $tag Quote Link to comment Share on other sites More sharing options...
paul2463 Posted May 13, 2007 Share Posted May 13, 2007 <?php $text = 'Johnny said "hi suzie"'; $tag = '<span style="color: red">"'; $pattern = '/\"/'; // double quotes echo preg_replace($pattern, $tag, $text); ?> prints out Johnny said <span style="color: red">"hi suzie<span style="color: red">" 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.