PHP

PHP Menu

PHP

strnatcasecmp() Function - Definition, Syntax, Parameters, Examples

Definition

The strnatcasecmp() function compares two strings using a "natural" algorithm.

Syntax

strnatcasecmp(string1, string2)

Parameters

Parameter Description
string1 Required. Specifies the first string to compare.
string2 Required. Specifies the second string to compare.

Example

<?php
// Example 1 echo strnatcasecmp("2PHP!", "10PHP!"); echo "<br>"; // Example 2 $arr1 = $arr2 = array("DSC1", "DSC2", "DSC10", "DSC01", "DSC100", "DSC20", "DSC30", "DSC200"); usort($arr2, "strnatcmp"); print_r($arr2);

Introduction

PHP Basics

PHP Advance

PHP OOP

PHP Functions and Methods