$ventura = new PostalCode("Ventura, CA"); /* You can get the distance to another location by specifying a zip code, city/state string, or another ZipCode object. You can specify whether you want to get the distance in miles or kilometers. */ echo "<h2>Get the distance between 2 zip codes</h2>"; $distance1 = round($portland->getDistanceTo("98501"), 2); $distance2 = round($portland->getDistanceTo($ventura, PostalCode::UNIT_KILOMETERS), 2); $distance3 = round($portland->getDistanceTo("Salem, OR"), 2); echo "Zip code <strong>{$portland}</strong> is <strong>{$distance1}</strong> miles away from " . "zip code <strong>98501</strong><br/>"; echo "Zip code <strong>{$portland}</strong> is <strong>{$distance2}</strong> <em>kilometers</em> away from " . "the city <strong>{$ventura}</strong><br/>"; echo "Zip code <strong>{$portland}</strong> is <strong>{$distance3}</strong> miles away from " . "the city <strong>Salem</strong><br/>"; /* You can get all of the zip codes within a distance range from teh zip. Here we are doing all zip codes between 0 and 2 miles. The returned array contains the distance as the array's key and the array element is another ZipCode object. */ echo "<h2>Get all zip codes between 10 and 15 miles from 97214</h2>"; foreach ($portland->getPostalCodesInRange(10, 15) as $miles => $zip) { $miles = round($miles, 1); echo "Zip code <strong>{$zip}</strong> is <strong>{$miles}</strong> miles away from " . " <strong>{$portland}</strong> ({$zip->getCounty()} county)<br/>"; } echo "<h2>Dump Database Row</h2>"; echo '<pre>'; print_r($portland->getDbRow()); echo '</pre>'; ?> </body> </html>