Change language

PHP Strnatcasecmp () Function

|
Syntax:
strnatcasecmp ($string1, $string2) 
Parameters:the function takes two required string parameters, as shown in the above syntax. These parameters are defined below:
  • $string1:This parameter specifies the first string to compare.
  • $string2:this parameter specifies the second row to compare.
Return Values:This function returns a positive integer, negative integer, or 0 based on the following conditions:
  • Returns 0,if the two strings are equal
  • Returns positive (> 0),if $string1 is greater than $string2.
  • Returns a negative value (< 0),if $string1 is less than $string2.
Examples:
 Input: $string = "Geek", $string2 = "GEEK" Output: 0 Input: $string = "Geeks", $string2 = "Geek" Output: 1 
The programs below illustrate the function strnatcasecmp ( ):Program 1:This program illustrates a simple use of the strnatcasecmp() function. echo strnatcasecmp ( "Geeks" , "Geek " );  
?>
Exit
1
Program 2:This program illustrates the case insensitivity of the strnatcasecmp() function.  
// case sensitive function strnatcasecmp() echo strnatcasecmp ( "Geeks" , "GEEKS" ); echo "" ;  
// Case-sensitive strnatcmp() function echo strnatcmp ( " Geeks " , " GEEKS " );  
?>
Exit
0 1 

PHP Strnatcasecmp () Function cmp: Questions

PHP Strnatcasecmp () Function PHP: Questions

Shop

Best laptop for Fortnite

$

Best laptop for Excel

$

Best laptop for Solidworks

$

Best laptop for Roblox

$

Best computer for crypto mining

$

Best laptop for Sims 4

$

Best laptop for Zoom

$499

Best laptop for Minecraft

$590

Latest questions

NUMPYNUMPY

psycopg2: insert multiple rows with one query

12 answers

NUMPYNUMPY

How to convert Nonetype to int or string?

12 answers

NUMPYNUMPY

How to specify multiple return types using type-hints

12 answers

NUMPYNUMPY

Javascript Error: IPython is not defined in JupyterLab

12 answers

Wiki

Python OpenCV | cv2.putText () method

numpy.arctan2 () in Python

Python | os.path.realpath () method

Python OpenCV | cv2.circle () method

Python OpenCV cv2.cvtColor () method

Python - Move item to the end of the list

time.perf_counter () function in Python

Check if one list is a subset of another in Python

Python os.path.join () method