Source Code:
(back to article)
<?php $string1 = "Hello World"; $string2 = "Hello"; $length = 5; $result = strncmp($string1, $string2, $length); if ($result < 0) { echo "The first $length characters of $string1 are less than the first $length characters of $string2"; } elseif ($result > 0) { echo "The first $length characters of $string1 are greater than the first $length characters of $string2"; } else { echo "The first $length characters of $string1 are equal to the first $length characters of $string2"; }
Result:
Report an issue