dude87121 Posted July 31, 2006 Share Posted July 31, 2006 How come the numbrs in $the cannot be replaced? They still show up in the same file. I am trying to get rid of a random combination of numbers using str_replace. Any help will be appreciated. Thanks.<?php $the='<?php hery 1 2 ?>';$num = array("1", "2", "3", "0");$dude = str_replace('hery'. $num. ' ?>', "", $the);$thecontent=fopen('testresults.php', 'w');fwrite($thecontent,$dude);?> Link to comment https://forums.phpfreaks.com/topic/16147-getting-rid-of-a-random-combination-of-numbers/ Share on other sites More sharing options...
trq Posted July 31, 2006 Share Posted July 31, 2006 Pardon? Link to comment https://forums.phpfreaks.com/topic/16147-getting-rid-of-a-random-combination-of-numbers/#findComment-66671 Share on other sites More sharing options...
ryanlwh Posted July 31, 2006 Share Posted July 31, 2006 use regex[code]<?php$dude = preg_replace('/(?<=hery)(\s*[0-9]\s*)*(?=\?\>)','',$the);?>[/code] Link to comment https://forums.phpfreaks.com/topic/16147-getting-rid-of-a-random-combination-of-numbers/#findComment-66681 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.