Hello,
I have data in the middle of a file that I need to be able to pull out of the file and replace...
Right now it looks like this:
<!--%START%-->
blah <br>
blah <br>
blah
<!--%END%-->
I'm trying to use the <!--%START%--> as a "beginning" point and the end as an end point....
The only code i have tried is :
<?
$grab_url = "http://www.someurl.com/dir/template.php";
$lines=file($grab_url);
// set up the start and end strings
$req_str="<--%START%-->";
$end_str="<--%END%-->";
// then scan each line for the required string
unset($the_str);
for($loop=0; $loop<count($lines); $loop++ )
{
if ( stristr($lines[$loop], $req_str) )
{
//got the start string now need to extract the bit we want
$startbit=strstr($lines[$loop], $req_str);
$endbit=strstr($lines[$loop], $end_str);
$str_pos=strlen($lines[$loop])-strlen($startbit);
$bit_len=strlen($startbit)-strlen($endbit);
$boneci=substr($lines[$loop], $str_pos, $bit_len);
break;
}
}
echo "$boneci";
?>
However this is not working. Does anyone know how to modify the code to work, or a completely seperate code that will ?