PHP strncmp function represents a binary safe comparison of several characters at the beginning of a string. The syntax is strncmp(string1,string2,length), the parameter string1 is required and specifies the first string to be compared, string2 must be specifies the second string to be compared...
How to use strncmp function?
Function: Compare the first n characters of the string, case sensitive
Syntax:
strncmp(string1,string2,length)
Parameters:
string1 Required, specified The first string to compare.
string2 Required, specifies the second string to be compared.
length Required, specifies the number of characters in each string used in the comparison.
Description: The strncmp() function compares two strings. strncmp() is binary-safe and case-sensitive. If the two strings are equal, 0 is output. If string1 is greater than string2, the output value is greater than 0. If string1 is less than string2, the output value is less than 0.
php strncmp() function usage example:
<?php echo strncmp("helloworld","Helloworld",6); ?>
Output:
1
This article is an introduction to the PHP strncmp function. I hope it will help you if you need Friends help!
The above is the detailed content of How to use php strncmp function. For more information, please follow other related articles on the PHP Chinese website!