Hi,
here is my idea / solution
$n = pow(2, $zoom);
// Tile Top Left
$lon_deg_top_left = $xtile / $n * 360.0 - 180.0;
$lat_deg_top_left = rad2deg(atan(sinh(pi() * (1 - 2 * $ytile / $n))));
// Tile Bottom Right
$lon_deg_bottom_right = ($xtile+1) / $n * 360.0 - 180.0;
$lat_deg_bottom_right = rad2deg(atan(sinh(pi() * (1 - 2 * ($ytile+1) / $n))));
// Tile Size
$lon_diff_tile = abs($lon_deg_bottom_right-$lon_deg_top_left);
$lat_diff_tile = abs($lat_deg_bottom_right-$lat_deg_top_left);
// Difference to Top Left
$lon_diff = abs($lon-$lon_deg_top_left);
$lat_diff = abs($lat-$lat_deg_top_left);
// Difference / x = TileSize / 256
$x = floor($lon_diff / $lon_diff_tile * 256);
$y = floor($lat_diff / $lat_diff_tile * 256);
Coach