Miscellaneous
|
|
|
|
<?php // Function - getMquest
// Passed:
// Variables..: 4 character strings; street, city, state,
// zip
// example of use..:
// echo getMquest('374 Center St', 'Winona', 'MN','55987');
// echo getMquest('374 Center St', 'Winona', 'MN','55987', 'link string');
// Above would create a link to MapQuest.com that would
//pull up a map of that location.
function getMquest($street, $city, $state, $zip, $link = '')
{
//Store the original address
$Address = array( 'street' => $street
, 'city' => $city
, 'state' => $state
, 'zip' => $zip
);
//Initialize local variables.
$Mlink = ""; //Return value
//Strip periods, commas, leading, and tailing spaces from street, city,
$street = trim($street);
$street = str_replace('.','',$street);
$street = str_replace(',','',$street);
$street = str_replace(' ','+',$street);
$city = trim($city);
$city = str_replace('.','',$city);
$city = str_replace(',','',$city);
$city = str_replace(' ','+',$city);
$zip = trim($zip);
$state = trim($state);
//Compine the given data into a url that will link to mapquest
$Mlink = "http://www.mapquest.com/cgi-bin/ia_find?link=btwn%2Ftwn-map_results&random=565&event=find_search&SNVData=&address=" .
$street . "&city=" . $city . "+&State=" . $state . "&Zip=" .
$zip . "&Find+Map.x=0&Find+Map.y=0";
switch(true){
case($link == ''):
$Mlink = "<a href=$Mlink>" . $Address['street'] . "<br>" .
$Address['city'] . ", " . $Address['state'] .
"<br>" . $Address['zip'] . "</a>";
break;
case($link != ''):
$Mlink = "<a href=$Mlink>$link</a>";
break;
}
return $Mlink;
} ?> ?>
|
|
|
Usage Example
|
echo "<a href=" . getMquest("374 center stret", "Winona", "MN", "55987") . ">click here to see my crib</A>";
|
|
|
Rate This Script
|
|
|
|