3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function IsEqual( $str,$str2 ) { $res = 0; for ($i=0, $max = count($str) -1; $i < $max; $i++) { if ( $str[$i] == $str2[$i]) { $res++; } else if ($str[$i] != $str2[$i]) { $res = 0; break; } } if (!$res) { return strlen($str) - strlen($str2); } else { return $res; } } $str = " 5"; $str2 = " 5"; $compRes = IsEqual($str,$str2); if (!$compRes){ echo "The \$str and \$str2 are the same.\n"; } else { echo "\$str is ",($compRes == 1)? "greater " : "less ", " than \$str2"; }
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
$str is less than $str2