3v4l.org

run code in 300+ PHP versions simultaneously
<?php $int = 12345; $digits = floor(log($int, 10)); echo "The 4th digit is: " . (floor($int / pow(10, 4)) % 10) . "\n"; echo "The 3rd digit is: " . (floor($int / pow(10, 3)) % 10) . "\n"; echo "The 2nd digit is: " . (floor($int / pow(10, 2)) % 10) . "\n"; echo "The 1st digit is: " . (floor($int / pow(10, 1)) % 10) . "\n"; echo "The 0th digit is: " . (floor($int / pow(10, 0)) % 10) . "\n";
Output for 7.1.25 - 7.1.27, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
The 4th digit is: 1 The 3rd digit is: 2 The 2nd digit is: 3 The 1st digit is: 4 The 0th digit is: 5

preferences:
104.65 ms | 1409 KiB | 4 Q