English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

PHP Basic Tutorial

PHP Advanced Tutorial

PHP & MySQL

PHP Reference Manual

PHP strnatcmp() function usage and example

PHP String 문자열 함수 매뉴얼

strnatcmp() function compares strings using natural sorting algorithm (case-sensitive).

syntax

int strnatcmp ( string $str1 , string $str2 )

definition and usage

It compares two strings using the natural order algorithm, case-sensitive.

return value

 Other string comparison functions, if str1 less than str2 return < 0; if str1 greater than str2 return > 0; 두자리가 같다면, return 0.

인수

순번인수와 설명
1

string1

첫 번째 문자열

2

string2

두 번째 문자열

온라인 예제

다음 예제를 시도하여 두 문자열의 크기를 비교해 보세요:

<?php
//대소문자 구분 없이 두 문자열을 비교합니다
echo strnatcmp("5w3codebox!","5w3codebox!");
echo "<br>";
//대소문자 구분 없이 두 문자열을 비교합니다
echo strnatcmp("5w3codebox!","5w3codebox!");
echo "<br>";
//두 번째 문자열이 첫 번째 문자열보다 큽니다
echo strnatcmp("5w3codebox!","58w3codebox!");
echo "<br>";
//두 번째 문자열이 첫 번째 문자열보다 작습니다
echo strnatcmp("101111w3codebox!","211w3codebox!");
?>
테스트 보세요‹/›

출력 결과

0
1
-1
1

PHP String 문자열 함수 매뉴얼