Php strcmp
From w3cyberlearnings
Contents |
PHP function strcmp
This function compares two strings, and it is case sensitive and is binary safe. This function is similar to strcoll() function.
Syntax strcmp
- string1: input 1
- string2: input 2
strcmp(string1, string2)
Return
- 0: when two string equal.
- >0: string1 is greater than string2.
- <0: string2 is greater than string1.
Example 1
<?php echo strcmp("Great Day","Great day"); ?>
Output: String2 is greater than String1
-1
Example 2
<?php echo strcmp("good","good"); ?>
Output
0