Hi, I need to file_get_contents of multiple website dynamically, so I use arrays in a loop to connect to. Here's a snippet: for ($i = 1; $i < sizeof($linkarray[0])-3; $i++){ echo ("<a href=" . $linkarray[1][$i] . "> <font color='red'><b>" . $linkarray[2][$i] . "</b></a></font><br><br> "); $ccontent = file_get_contents($linkarray[1][$i]); $rele = preg_match("/".$pieces[0].".*/", $ccontent, $rel); ECHO $rel[0]."<BR><BR>"; } PHP: So it loops, and gets the contents of some sites, yet when I echo the output array $rel[0]; I get Failed to stream for each one, despite them being valid URLs. If someone could help it would be great , Thanks, Lee.
$linkarray is just a simple array with data. $linkarray[1][$x] contains all the URLs. I get errors like: Warning: file_get_contents("http://www.autotrader.co.uk/"): failed to open stream: No such file or directory in /home/hydropow/public_html/izearch/searched.php on line 173 Code (markup): Anyone help?
It sounds like the allow_url_fopen is disabled, which means remote pages can't be fetched. You can change this in the php.ini file or with ini_set('allow_url_fopen', 1); in your script More info at php.net: php.net/manual/en/ref.filesystem.php#ini.allow-url-fopen
Hm, Just tried it, it didn't work I think it may be the array.. does anyone know the most simple way to turn an array into a string? Thanks, Lee.
Did you try with the php.ini or ini_set()? According to the php.net changelog ini_set() only works with "PHP_INI_ALL in PHP <= 4.3.4". You can check allow_url_fopen with <?php echo ini_get('allow_url_fopen'); // or this function echo phpinfo(); // look under "PHP core" ?> PHP: Hope this can help you.
I solved the problem myself lol Thanks for all your help, I needed to explode() the array and get rid of the "" around the URL.