strncmp() function in PHP

WBOY
Release: 2023-08-19 15:34:01
forward
1190 people have browsed it

strncmp() function in PHP

strncmp() function is used to compare the first n characters.

Note- This function is case sensitive.

Syntax

strncmp(str1, str2, len)
Copy after login

Parameters

  • ##str1− The first string

  • str2− The second string

  • len− The number of characters used for comparison.

Return value

strncmp() 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

Copy after login

Output

The following is the output−

8192
Copy after login

Example

Let’s see another example −

Real time demonstration

Copy after login

Output

The following is the output−

-32
Copy after login

The above is the detailed content of strncmp() function in PHP. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!