I wrote a program to reverse the number in online compiler. I've checked my code on three online compilers. On writephponline and paiza.io I'm getting correct output, whereas on phpfiddle.org I'm getting some strange answer?
What is it that is producing different Output?
I've used floor function for rounding up the value but that doesn't make any difference I guess.
function reverse($n){
$count = strlen((string)$n);
$b=0;
for($i=0;$i<$count;$i++){
$a = $n%10;
$n = floor($n/10);
$b = ($b+$a)*10;
}
return $b/10;
}
echo reverse(123456789);
I expect same answer on all the online compilers but getting different output.