All pastes #468239 Raw Edit

Stuff

public php v1 · immutable
·published 2007-05-02 23:36 UTC
rendered paste body
<?php// {{{ class LongLat/** * Longitude-Latitude utilities *  * This function will include the static functions (collection of methods) * that are going to be used to help with the longitude and latitude coords. *  * @version 0.1.0 * @license LGPL-CC * @copyright 1line * */class Util_LongLat{    // {{{ public static function getCoord    /**     * Get Coords     *      * This function retrieves the coords of a givent url.     *     * @param  string $type    The type, either longitude or latitude     * @param  string $content The content of the page to parse.     * @return string The value of the parsed content.     */    public static function getCoord($type = 'latitude', $content)    {        switch (strtolower($type)) {            case 'longitude':            case 'latitude':                $type = (string)$type;        }                preg_match("/<dd class=\"$type\">(.*[^>])<\/dd>/", $content, $values,  PREG_OFFSET_CAPTURE);                if (is_array($values) && isset($values[1][0])) {            preg_match("/\((.*[^\)])\)/", $values[1][0], $lastvalues, PREG_OFFSET_CAPTURE);            if (is_array($lastvalues) && isset($lastvalues[1][0])) {                return (string)$lastvalues[1][0];            }        }        return 'none';    }    // }}}}// }}}$latitude  =  '';$longitude =  '';if (strtolower((string)$county) == 'uk') {    $content = file_get_contents("http://www.multimap.com/map/browse.cgi?client=public&search_result=&db=pc&keepicon=true&lang=&pc=cm16%206rp&advanced=&client[equal%20tongue]ublic&addr2=&quicksearch=cm16%206rp&addr3=&addr1=");    $latitude  = Util_LongLat::getCoord('latitude', $content);    $longitude = Util_LongLat::getCoord('longitude', $content);    echo "Latitude: $latitude\n";    echo "Longitude: $longitude";}?>