Jump to content

[HELP] File_Get_Contents


BRUm

Recommended Posts

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:

[code=php:0]
      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>";

      }
[/code]


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.
Link to comment
https://forums.phpfreaks.com/topic/18705-help-file_get_contents/
Share on other sites

It's not a complicated array, just the basic:

[/code]
[1] => Array
        (
            [0] => "http://froogle.google.co.uk/froogle?=en&q=cars&btnG=Google+Search&sa=N&tab=wf"
            [1] => "/movies/reviews?cid=b3d997eccb5717fb&fq=cars&sa=X&oi=showtimes&ct=reviews&cd=2"
            [2] => "http://www.channel4.com/4car/"
            [3] => "http://www.cars.com/"
            [4] => "http://www.autotrader.co.uk/"
            [5] => "http://uk.cars.yahoo.com/"
            [6] => "http://www.imdb.com/title/tt0317219/"
            [7] => "http://www.carsthemovie.com/"
)
[/code]

This is only the $linkarray[1][$i] part. $linkarray[0] and [2] contain other stuff.
Link to comment
https://forums.phpfreaks.com/topic/18705-help-file_get_contents/#findComment-80656
Share on other sites

First couple of elements look as though they should be all 1 element
[code]<?php
$linkarray = array (
        1 => array( 

        "http://froogle.google.co.uk/froogle?=en&q=cars&btnG=Google+Search&sa=N&tab=wf/movies/reviews?cid=b3d997eccb5717fb&fq=cars&sa=X&oi=showtimes&ct=reviews&cd=2",
        "http://www.channel4.com/4car/",
        "http://www.cars.com/",
        "http://www.autotrader.co.uk/",
        "http://uk.cars.yahoo.com/",
        "http://www.imdb.com/title/tt0317219/",
        "http://www.carsthemovie.com/",
        )
);

$ccontent = file_get_contents($linkarray[1][0]);
echo $ccontent;
?>[/code]
Link to comment
https://forums.phpfreaks.com/topic/18705-help-file_get_contents/#findComment-80659
Share on other sites

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.