3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function intdiv_2($a, $b){ return floor($a / $b); } function isBouncy($num) { if ($num < 100) { return false; } $ni = true; $nd = true; $lastDigit = $num % 10; $num = intdiv_2($num, 10); while($num != 0) { $digit = $num % 10; if ($digit > $lastDigit) { $nd = false; } else if ($digit < $lastDigit) { $ni = false; } $lastDigit = $digit; $num = intdiv_2($num, 10); } return !$ni && !$nd; } var_dump(isBouncy(0)); var_dump(isBouncy(10)); var_dump(isBouncy(345)); var_dump(isBouncy(321)); var_dump(isBouncy(384));
based on ZmmPL
Output for 5.3.19 - 7.2.0
bool(false) bool(false) bool(false) bool(false) bool(true)