DamienRoche Posted October 19, 2008 Share Posted October 19, 2008 Hi. I am just wondering if I can combine multiple preg_replaces. For example: <?php $str = "this is a string 123 ABC"; $var = "this is a"; $newstr = preg_replace("#[A-Z]#", "", $str); $newstr = preg_replace("#$var#", "", $str); ?> Is there a way to combine the $var and the character set? Thanks. Link to comment https://forums.phpfreaks.com/topic/129035-combining-multiple-preg_replaces/ Share on other sites More sharing options...
The Little Guy Posted October 19, 2008 Share Posted October 19, 2008 $str = "this is a string 123 ABC"; $var = "this is a"; $find = array("#[A-Z]#","#$var#"); $replace = array("",""); $newstr = preg_replace($find,$replace, $str); Link to comment https://forums.phpfreaks.com/topic/129035-combining-multiple-preg_replaces/#findComment-668945 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.