<?php class calc { public function doCalc($date, $dow){ $md5 = md5($date."-".$dow); list($lat,$lng) = str_split($md5,16); return array($this->hex2dec($lat), $this->hex2dec($lng)); } private function hex2dec($var){ $o = 0; for($i=0;$i<16;$i++){ $o += hexdec($var[$i])*pow(16,-$i-1); } return $o; } } ?>
usage:
<?php $calc = new calc(); list($lat, $lng) = $calc->doCalc($date, $dow); ?>
- for $date the date of the hash should be filled in in the format yyyy-mm-dd
- for $dow the dow that should be used should be filled in with a dot as decimal sign.