← All built-ins / strcmp()
strcmp()
strcmp(string $a, string $b): int
Parameters
| Name | Type | Description |
|---|---|---|
| $a | string | first string |
| $b | string | second string |
Return value
< 0 when $a sorts before $b, 0 when equal, > 0 when $a sorts after $b.
Example
echo strcmp("apple", "banana"), "
";
echo strcmp("same", "same"), "
";
echo strcmp("b", "a"), "
";-1 0 1