Jump to content

Archived

This topic is now archived and is closed to further replies.

BRUm

[HELP] File_Get_Contents

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.

Share this post


Link to post
Share on other sites
How is your array structured?

[code]echo '<pre>', print_r($linkarray, true), '</pre>';[/code]

Share this post


Link to post
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.

Share this post


Link to post
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]

Share this post


Link to post
Share on other sites
But if they're all one element, then how do I distinguish between each one? I need to use each individual URL and it's dynamic too.

Thanks for your help.

Share this post


Link to post
Share on other sites
There are seven elements in the array I posted - there were 8 in yours. I combined the first 2.

Share this post


Link to post
Share on other sites
Ah right, yes I understand. Still, I get:

[code]Warning: file_get_contents("http://www.carsthemovie.com/"): failed to open stream: No such file or directory in /home/hydropow/public_html/izearch/searched.php on line 161[/code]

Share this post


Link to post
Share on other sites
It is allowed because when I manually use:

[code=php:0]
$test = Get_File_Contents("http://www.example.com");
echo $test;
[/code]

That streams and returns fine.. :/

Share this post


Link to post
Share on other sites

×

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.