← All built-ins / strncmp()

strncmp()

strncmp(...$args): int

Parameters

NameTypeDescription
$astringfirst string
$bstringsecond string
$nintmaximum bytes to compare

Return value

Like strcmp(), limited to the first $n bytes.

Example

echo strncmp("holyphp", "holyphp2", 7);
0

See also

strcmp()strncasecmp()