PHPRO.ORG

Geo targetting and geo location are often done within the database. However, there are times when you need to feed the database the values as radians. Some simple math produces the required result.

This function is already available within PHP itself using deg2rad() and is show n here for example only.


<?php

/*
 *
 * @convert degrees to radians 
 *
 * @param float $degrees
 *
 * @return float
 *
 */
function DegreeToRadian($degrees
{
    
/*** do the math ***/
    
return $degrees pi() / 180
}

/*** example usage ***/
$degrees 23;

echo 
DegreeToRadian$degrees );

?>