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 Link to comment https://forums.phpfreaks.com/topic/51156-quick-search-and-replace-wih-variables/ 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">" Link to comment https://forums.phpfreaks.com/topic/51156-quick-search-and-replace-wih-variables/#findComment-251911 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.