help please I want to make acode that have auto get function example $urls = array( 1 => "http://example.com", 2 => "http://example1.com", 3 => "http://example3.com", and when i request the urls it 'll be auto changed at every time i request $urls please any person help me
You dont give any details as to what is available, or the URLs you are requesting but it should be pretty simple using CURL. E.G <?php $urls = array('http://www.example.com', 'http://www.example2.com'); foreach($urls as $url) { $html = get($url); # do stuff with the requested URL here. EG print $html."\n-------------------------\n"; } function get($url) { $headers=array(); # Add your custom headers as required, EG $headers[]='Connection: Keep-Alive'; $headers[]='Content-type: application/x-www-form-urlencoded;charset=UTF-8'; $process = curl_init($url); curl_setopt($process, CURLOPT_HTTPHEADER, $headers); curl_setopt($process, CURLOPT_HEADER, false); curl_setopt($process, CURLOPT_USERAGENT, 'YOURUA'); curl_setopt($process, CURLOPT_TIMEOUT, 10); curl_setopt($process, CURLOPT_RETURNTRANSFER, 1); curl_setopt($process, CURLOPT_FOLLOWLOCATION, 1); curl_setopt ($process, CURLOPT_SSL_VERIFYPEER, false); $return = curl_exec($process); curl_close($process); return $return; } PHP:
Thank you this is working but iwant to redirect to the requested page $urls = array('http://www.example.com', 'http://www.example2.com'); and there is an error that it's get all requested pages at the page iwant it only redirect auto to one page
Im a little confused about what it is you are trying to do exactly. You can redirect to one of them using the header function; http://php.net/manual/en/function.header.php If you want to redirect to a random URL, something like; <?php $urls = array("http://www.example1.com", "http://www.example2.com"); header("location: ".$urls[rand(0,(sizeof($urls)-1))); PHP: If you want to be able to specify the URL you are redirecting too, you will need to pass it through using post, get, session etc etc and then process the array in a similar way.
Hi Frnd, I joined to a PHP & Unix/Linux groups, which contains Materials, Jobs Interview Questions & Interview Kit for Free too. If you like it join my groups go this URL=. http://groups.yahoo.com/group/OneStopPHP/join URL=http://groups.yahoo.com/group/OneStopUNIX/join