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);?> Quote Link to comment Share on other sites More sharing options...
trq Posted July 31, 2006 Share Posted July 31, 2006 Pardon? Quote Link to comment 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] 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.