3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $lat = 60; $lon = 160; $zoom = 2; $nLon = ($lon / 360) + 0.5; $nLat = abs((asinh(tan(deg2rad($lat))) / M_PI / 2) - 0.5); $scale = 1 << $zoom; $tileX = (int)($nLon * $scale); $tileY = (int)($nLat * $scale); var_dump($tileX, $tileY);
Output for 4.3.0 - 7.1.0
int(3) int(1)