[thelist] condensing 4 regexes to 1?
der wert
derwert at hotmail.com
Sat Aug 5 19:26:34 CDT 2006
you use selectors "(abc)(def)(ghi)"
code:
<?php
$myurl = "http://maps.google.co.uk/maps?q=ab106qr&output=js";
$myhtml = getURL($myurl);
$pattern = '/center: \{lat: ([-]?[0-9]{1,3}\.[0-9]{6}),lng:
([-]?[0-9]{1,3}\.[0-9]{6})/';
preg_match($pattern, $myhtml , $matches);
/*print_r($matches);*/
echo "latitude: ".$matches[1]." longitude: ".$matches[2];
function getURL($popped){
$fail = "failed";
$remote = @fopen ($popped, "rb");
if (!$remote){
print($popped." FAILED");
return $fail;
}
else{
$html = "";
do {
$data = fread($remote, 8192);
if (strlen($data) == 0) {
break;
}
$html .= $data;
} while(true);
fclose ($remote);
return $html;
}
}
?>
D
On 8/5/06, Alex Beston <alex.beston at gmail.com> wrote:
>Hi evolters
>
>http://www.markbarton.com/blog/articles/FAST-6E8BQF contains a hack to
>get the post code out of a gmap's url output and mentions it can be
>parsed out. this is a proof of concept for a mashup im making rather
>than an actual attempt to rip off google, so bear with me.
_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today - it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
More information about the thelist
mailing list