English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
PHP String Character String Function Manual
The strncmp() function is used for binary-safe comparison of the first few characters of strings (case sensitive).
int strncmp ( string $str1 , string $str2 , int $len )
Used to compare the first len characters.
If str1 Less than str2 Returns < 0; if str1 Greater than str2 Returns > 0; if they are equal, return 0.
Serial Number | Parameters and Description |
---|---|
1 | string1 First String |
2 | string2 Second String |
3 | len Maximum Comparison Length |
Try the following example to compare two strings (case sensitive):
<?php //strncmp function compares two strings (case sensitive) echo strncmp("input","input",6); echo "<br>"; echo strncmp("input","iMPut",6); ?>Test and see‹/›
Output Result
0 8448