strncasecmp() function in PHP


The strncasecmp() function is used to compare two strings.

Note − The function is case-insensitive.

Syntax

strncasecmp(str1,str2,len)

Parameters

  • str1 − First string to compare

  • str2 − Second string to compare

  • len − The length of strings to be used while comparing

Return

The strcoll() 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 −

Live Demo

<?php
   echo strncasecmp("Demo text!","DEMO word!",4);
?>

Output

0

Updated on: 30-Jul-2019

70 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements