Jump to content

Archived

This topic is now archived and is closed to further replies.

dude87121

Getting rid of a random combination of numbers

Recommended Posts

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

Share this post


Link to post
Share on other sites
use regex
[code]<?php
$dude = preg_replace('/(?<=hery)(\s*[0-9]\s*)*(?=\?\>)','',$the);
?>[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.