Jump to content


Photo

Getting rid of a random combination of numbers


  • Please log in to reply
2 replies to this topic

#1 dude87121

dude87121
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 31 July 2006 - 09:57 PM

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);
?>

#2 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 31 July 2006 - 10:00 PM

Pardon?

#3 ryanlwh

ryanlwh
  • Staff Alumni
  • Advanced Member
  • 511 posts

Posted 31 July 2006 - 10:16 PM

use regex
<?php
$dude = preg_replace('/(?<=hery)(\s*[0-9]\s*)*(?=\?\>)','',$the);
?>

Please use EDIT * 100...
Please use
or [php] * 1000...

PLEASE READ THE POSTED SOLUTIONS CAREFULLY * 1000000...




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users