- str_split: documentation ( source)
<?php
function isDivisible_x_3($n)
{
if (strlen($n) == 3){
list($a,$b,$c) = str_split($n);
if ($b == $a + 1 && $c == $b + 1){
$mess = "\n$n is divisible by three\n";
$mess .= "\nProof: \$n//3 == " . $n/3;
return $mess;
}
}
}
$num = 234;
echo isDivisible_x_3( $num );