I need “calculate” an URL and redirect to it. I have the following code:
<?php
//Basic HTML parsing with PHP
include("simple_html_dom.php");
$htmlCode = file_get_html('http://example.net/example.html');
foreach($htmlCode->find('div[class=frontPageImage]') as $element) {
foreach($element->find('img') as $imagee)
$imgurl = $imagee->src;
}
header("'Location:".$imgurl."'");
?>
First in $imgurl get the url and later redirect to that url… but it doesn’t work..
any idea or suggestion? thanks
Should probably be:
I removed the single quote
'because your HTTP header would look like:which is invalid because of the single quotes.
You are also looping and finding many image URL’s but only redirecting to the last one.