function GetLatLong($postcode){
$myKey = 'Your_Google_API_Key_Here';
$URL = "http://maps.google.co.uk/maps/geo?q=" . urlencode($postcode) . "&output=json&key=".$myKey;
$data = file($URL);
if($data){
$data = json_decode($data[0]);
$long = $data->Placemark[0]->Point->coordinates[0];
$lat = $data->Placemark[0]->Point->coordinates[1];
return array('Latitude'=>$lat,'Longitude'=>$long);
}else return false;
}
Tag Archive for code
Find the Latitude and Longitude of a ZIP/Postcode using Google
Dump a file to the terminal, starting at some line number
tail -n+99 foo.txt | more
Hide Myspace Comments
<style type="text/css">
table.friendsComments {
display: none;
visibility: hidden;
}
</style>
PHP (RegEx) Zip Code Validation
$string = "12345-1234";
if (preg_match('/^[0-9]{5}([- ]?[0-9]{4})?$/', $string)) {
echo "zip code checks out";
}
Code
<?php
$product_info_query = tep_db_query("select pd.products_name, p.products_model from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");
$product_info = tep_db_fetch_array($product_info_query);
$products_name = $product_info['products_name'];
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE . " - " . $products_name; ?></title>
some Smart Code
protected void setUp() throws Exception {
queue = new ClipBoardQueue();
}
Sample ASP Code
public void testRefreshAddsCurrentElementAtTopAndRemovesLastContentIfClipBoardContentsAreChangedAndOfMaxSize() {
queue = mockClipBoardQueue(true, "New Content");
insertDummyValuesIntoQueue(2);
assertTrue(queue.refresh());
assertEquals(3, queue.getQueue().size());
assertEquals("New Content", queue.getQueue().getFirst());
}
Sample C# code new
public void testClipBoardContentsAreChangedWhenQueueIsEmptyContentProvided() {
assertTrue(queue.isClipBoardContentsChanged("New Content"));
}
Other Language Code
public void testClipBoardContentsAreChangedWhenQueueIsEmptyContentProvided() {
assertTrue(queue.isClipBoardContentsChanged("New Content"));
}