PHP Classes

how do I extract variables from within a string?

Recommend this page to a friend!

      Top level forums  >  PHP Specialists  >  General  >  how do I extract variables from...  
Subject:how do I extract variables from...
Summary:cUrl gets a webpage which changes and I want to extract data
Messages:3
Author:Erok
Date:2009-05-13 16:41:28
Update:2009-05-14 06:04:50
 

  1. how do I extract variables from...   Reply   Report abuse  
Picture of Erok Erok - 2009-05-13 18:18:54
I am creating a script that search imdb for a film based on a badly inputed film name. e.g.

$file="Madagascar-Escape.2.Africa[2008].cool_film [eng]";
$search = anafilm($file);
$q=str_ireplace(" ","+",$search['search']);

echo $url = "http://www.imdb.com/find?q=".$q.";s=tt";
$ch = curl_init(); // initialize curl handle
curl_setopt($ch, CURLOPT_URL,$url); // set url to post to
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);// allow redirects
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return into a variable
curl_setopt($ch, CURLOPT_TIMEOUT, 3); // times out after 4s
$result = curl_exec($ch); // run the whole process
curl_close($ch);

I made a function called anafilm() that analyses $file to extract the year and the language so "Madagascar Escape 2 Africa cool film" will be searched. I want to extract all the possible titles from the resulting page (http://www.imdb.com/find?q=Madagascar+Escape+2+Africa+cool+film) which is $result.

This is the first time i've used cUrl properly. Thanks

There are 2 replies in this thread, which are not being displayed.
Browsing this forum thread replies is available only to premium subscribers.


Go to the premium subscriptions page to learn how to become a premium subscriber and have full access to this forum.