Jump to content

help with file_get_contents function


bicho83

Recommended Posts

I am trying to grab a specific portion of a file, I went to php.net to read about the function and I followed one of the comments scripts which its suppose to do what I want.

 

<?
$content=file_get_contents("http://www.google.com",FALSE,NULL,0,20);
echo $content;
?>

This will echo the 20 first bytes of the google.com source code.

 

So I tried that with the script that I want to develop:

$cod_4_raw_file_grabber = file_get_contents("http://www.gametracker.com/server_info/91.151.97.35:28960/",TRUE,NULL,11682,22000);
$cod_4_raw_file_grabber = file_put_contents("raw_files/cod_4_raw_file.txt",$cod_4_raw_file_grabber);

 

I want the script to grab that (absolute path) file and that starts at 11682 bytes, and ends (it ends pretty much at 22000+ bytes).

 

I am not sure what the "TRUE", or "NULL" really do.

When I ran the file_get_contents with only the path and the "TRUE" it works fine.

 

I am running my website or page in php 5.2.5 and apache 1.3.37 according to Siteground.

 

Please help me out.

 

Link to comment
https://forums.phpfreaks.com/topic/99862-help-with-file_get_contents-function/
Share on other sites

Because I want a portion of the file, not the entire thing. That's what's not working. I am specifying that I want from 11682 bytes to the end of the file (or 22000 bytes) but it doesn't get anything. It gives me a 0 byte file because it's not grabbing anything.

Please somebody help me, I need to know why is returning me a blank file when I run the following line:

$cod_4_raw_file_grabber = file_get_contents("http://www.gametracker.com/server_info/91.151.97.35:28960/",TRUE,NULL,11682,22000);

 

But when I don't tell the function the amount of bytes "from" and "to" it works. I have php 5.2.5.

Archived

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

×
×
  • Create New...

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.