3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function luhn($number) { settype($number, 'string'); $sumTable = array( array(0,1,2,3,4,5,6,7,8,9), array(0,2,4,6,8,1,3,5,7,9)); $sum = 0; $flip = 0; for ($i = strlen($number) - 1; $i >= 0; $i--) { $sum += $sumTable[$flip++ & 0x1][$number[$i]]; } return $sum % 10 === 0; } $arr = array(); foreach(range(0,120) as $num) { if ($num % 3 === 0) { $arr[] = $num; } } echo implode(' ,', $arr);
Output for 4.3.0 - 5.6.28, hhvm-3.12.0, 7.0.0 - 7.1.0
0 ,3 ,6 ,9 ,12 ,15 ,18 ,21 ,24 ,27 ,30 ,33 ,36 ,39 ,42 ,45 ,48 ,51 ,54 ,57 ,60 ,63 ,66 ,69 ,72 ,75 ,78 ,81 ,84 ,87 ,90 ,93 ,96 ,99 ,102 ,105 ,108 ,111 ,114 ,117 ,120
Output for hhvm-3.10.0

Process exited with code 153.