strcmp is a string compare function that is available in languages such as C, C++, PHP, Python and MATLAB.
strcmp
is a string compare function that is available in languages such as C, C++, PHP, Python and MATLAB.
Structure
PHPint strcmp ( string $str1 , string $str2 )
C
int strcmp( const char *lhs, const char *rhs );
Returns < 0 if str1 is less than str2; > 0 if str1 is greater than str2, and 0 if they are equal.
Examples
PHPecho strcmp("a","z"); // returns a negative number
echo strcmp("a","a"); // returns 0
echo strcmp("z","a"); // returns a positive number
C
int res = strcmp("a", "z"); // result is a negative number
int res = strcmp("a", "a"); // result is 0
int res = strcmp("z", "a"); // result is a positive number