It seems that you have missed out the assignment operator in the PHP version of the script.
Code snippet with the changes made
function calcZoom($accuracy) {
for ($n = 10, $o = 2; $n * 320 > $accuracy; ) {
$n /= 2;
$o++;
}
return min(16, $o);
}
Code walkthrough:
Since the statement was $n / 2
the value of the variable did not change.
Changing it to an $n /= 2
assigned the value to the variable and thus fixed your issue.
5
solved Convert JavaScript for loop to php [closed]