- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
strnatcmp() function in PHP
The strnatcmp() function is used compare two strings with a natural order algorithm.
Syntax
strnatcmp(str1, str2)
Parameters
str1 − First string to compare.
str2 − Second string to compare
Return
The strnatcmp() function returns −
0 - if the two strings are equal
<0 - if string1 is less than string2
>0 - if string1 is greater than string2
Example
The following is an example −
<?php echo strnatcmp("Test", "TEST"); ?>
Output
The following is the output −
1
Example
Let us see another example −
<?php echo strnatcmp("5Demo", "50DEMO"); echo "
"; echo strnatcmp("50Demo", "5DEMO"); echo "
"; echo strnatcmp("100Demo", "100Demo"); ?>
Output
The following is the output −
-1 1 0
Advertisements
To Continue Learning Please Login
Login with Google