What I'm attempting to do is post multiple url's which are exploded by a line break, get and then concatenate the contents of all files.
The problem is, it returns;
Warning: file_get_contents(http://www.domain.com/emails.html ) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /nfs/c09/h02/mre/137842/domains/domain.com/html/index.php on line 6
For all but the last url.
Things that I've noted;
- I've tried using
urlencode()
but that completely destroys the HTTP request. - There seems to be a space between the last character of the URL and the closing bracket, when I attempt to enter the url with a space into the browser it works fine (but this could be the browser rewriting an invalid URL?)
Here's my code for good measure;
$urls = explode("\n", $_POST['urls']);
$allTexts = '';
foreach($urls as $url)
{
$text = file_get_contents($url);
if (false === $text)
continue;
// proceed with your text, e.g. concatinating it:
$allTexts .= $text;
}
Any advice or comments would be greatl开发者_运维技巧y appreciated (although I'd rather not use cURL if I don't need to :))!
精彩评论