bicho83 Posted April 6, 2008 Share Posted April 6, 2008 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 More sharing options...
doni49 Posted April 6, 2008 Share Posted April 6, 2008 I believe that the TRUE is telling PHP that it can use the INCLUDE PATH (search path) to find the file. But since you're spec'ing the absolute path, you shouldn't need that. That being said, if it's working--what's the trouble? Link to comment https://forums.phpfreaks.com/topic/99862-help-with-file_get_contents-function/#findComment-510718 Share on other sites More sharing options...
bicho83 Posted April 6, 2008 Author Share Posted April 6, 2008 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. Link to comment https://forums.phpfreaks.com/topic/99862-help-with-file_get_contents-function/#findComment-510773 Share on other sites More sharing options...
bicho83 Posted April 7, 2008 Author Share Posted April 7, 2008 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. Link to comment https://forums.phpfreaks.com/topic/99862-help-with-file_get_contents-function/#findComment-511412 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.