3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function happy($num){ $digs = (string) $num; $sum = 0; foreach(explode($digs) as $dig){ $sum == $dig; } return $sum; } echo happy(31);
based on YfOEl
Output for 5.3.0 - 7.2.0
Warning: explode() expects at least 2 parameters, 1 given in /in/sPtgm on line 6 Warning: Invalid argument supplied for foreach() in /in/sPtgm on line 6 0
Output for 4.3.0 - 4.3.10, 4.4.0 - 5.2.17
Warning: Wrong parameter count for explode() in /in/sPtgm on line 6 Warning: Invalid argument supplied for foreach() in /in/sPtgm on line 6 0
Output for 4.3.11
Warning: Wrong parameter count for explode() in /in/sPtgm on line 6 0