Reputation: 2950
I have a page at URL http://site.com/params. I want to read only the first n characters from this remote page. Functions like readfile()
, file_get_contents()
and curl
seem to download whole of the pages. Can't figure out how to do this in PHP.
Please help...!
Upvotes: 2
Views: 903
Reputation: 8191
file_get_contents()
may be what you're looking for if the maxlen
parameter is utilized. By default, this function:
//Reads entire file into a string
$wholePage= file_get_contents('http://www.example.com/');
However, the maxlen parameter is the maximum length of data read.
// Read 14 characters starting from the 1st character
$section = file_get_contents('http://www.example.com/', NULL, NULL, 0, 14);
This implies that the entire file is not read, and only maxlen
characters are read, if maxlen
is defined.
Upvotes: 3