Closed Thread
Results 1 to 3 of 3

Thread: HELP! - file_get_contents

  1. #1
    maros174 is offline Newbie
    Join Date
    Oct 2009
    Posts
    2
    Rep Power
    0

    HELP! - file_get_contents

    Hi all,

    How can I "fill" the varable $html with the contents from two files(locations), using the same function file_get_contents ?
    Below is a part of the code that I use, it is working perfectly - I just need to collect the data from two web addresses (instead of one) and place it inside the variable $html

    Any help will be hugely appreciated...

    Code:
            $html=file_get_contents('SOME-WEB-ADDRESS');
            $pattern="|<tr[^>]+tip='D'>(.*)</tr+>|U";
            preg_match_all($pattern, $html, $elements);
            $MasterData=array();
            
            foreach($elements[1] AS $ei => $element){
                $pattern="|Model=(.*)'|U";
                preg_match_all($pattern, $element, $Info);
                $pattern="|<td+>(.*)</td+>|U";
                preg_match_all($pattern, $element, $MultiData);
      
                foreach($MultiData[1] AS $tdi => $Data)
                    $MasterData[$Info[1][0]][$tdi]=$Data;
            }
            
            foreach($Data AS $oznaka => $data1){....and the code goes on.....

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    Jacki's Avatar
    Jacki is offline Learning Programmer
    Join Date
    Sep 2009
    Location
    Switzerland
    Posts
    80
    Rep Power
    9

    Re: HELP! - file_get_contents

    file_get_contents() return a string, you can concatenate the two string:
    Code:
    $html file_get_contents('page1').file_get_contents('page2'); 
    but I think it's useless.. what does your script do?
    You can also make a function that contain your script and you use it for the two pages...



  4. #3
    maros174 is offline Newbie
    Join Date
    Oct 2009
    Posts
    2
    Rep Power
    0

    Re: HELP! - file_get_contents

    Thanks. It worked like a charm.
    The script collects stock market data from two pages, processes it and stores it in a database.

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Warning: file_get_contents() [function.file-get-contents]
    By Bioshox in forum PHP Development
    Replies: 1
    Last Post: 09-22-2011, 03:13 AM
  2. WAMP file_get_contents($url) problem
    By hhheng in forum PHP Development
    Replies: 3
    Last Post: 03-17-2010, 04:03 PM
  3. File_get_contents problem
    By webcodez in forum PHP Development
    Replies: 1
    Last Post: 03-08-2010, 03:30 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts