Compare two strings using a "natural" algorithm (case-sensitive) in PHP

Description

The following code shows how to compare two strings using a "natural" algorithm (case-sensitive).

Example


//  ww w  .ja  v  a2s.c o m
<?php
    echo strnatcmp("2Hello world!","10Hello world!");
    echo "<br>";
    echo strnatcmp("10Hello world!","2Hello world!");
?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    Data Types »




Array
Array Associative
Array Util
ArrayObject
Data Types
Date
Date Format
DateTime
Number
String
String Escape
String Filter
String HTML
String Type
Timezone