1--TEST--
2Test strnatcmp() function : basic functionality
3--FILE--
4<?php
5/* Prototype  : int strnatcmp  ( string $str1  , string $str2  )
6 * Description: String comparisons using a "natural order" algorithm
7 * Source code: ext/standard/string.c
8*/
9echo "*** Testing strnatcmp() : basic functionality ***\n";
10
11$a1 = "abc1";
12$b1 = "abc10";
13$c1 = "abc15";
14$d1 = "abc2";
15
16$a2 = "ABC1";
17$b2 = "ABC10";
18$c2 = "ABC15";
19$d2 = "ABC2";
20
21echo "Less than tests\n";
22var_dump(strnatcmp($a1, $b1));
23var_dump(strnatcmp($a1, $c1));
24var_dump(strnatcmp($a1, $d1));
25var_dump(strnatcmp($b1, $c1));
26var_dump(strnatcmp($d1, $c1));
27
28var_dump(strnatcmp($a1, $b2));
29var_dump(strnatcmp($a1, $c2));
30var_dump(strnatcmp($a1, $d2));
31var_dump(strnatcmp($b1, $c2));
32var_dump(strnatcmp($d1, $c2));
33
34
35echo "Equal too tests\n";
36var_dump(strnatcmp($b1, $b1));
37var_dump(strnatcmp($b1, $b2));
38
39echo "Greater than tests\n";
40var_dump(strnatcmp($b1, $a1));
41var_dump(strnatcmp($c1, $a1));
42var_dump(strnatcmp($d1, $a1));
43var_dump(strnatcmp($c1, $b1));
44var_dump(strnatcmp($c1, $d1));
45
46var_dump(strnatcmp($b1, $a2));
47var_dump(strnatcmp($c1, $a2));
48var_dump(strnatcmp($d1, $a2));
49var_dump(strnatcmp($c1, $b2));
50var_dump(strnatcmp($c1, $d2));
51?>
52===DONE===
53--EXPECT--
54*** Testing strnatcmp() : basic functionality ***
55Less than tests
56int(-1)
57int(-1)
58int(-1)
59int(-1)
60int(-1)
61int(1)
62int(1)
63int(1)
64int(1)
65int(1)
66Equal too tests
67int(0)
68int(1)
69Greater than tests
70int(1)
71int(1)
72int(1)
73int(1)
74int(1)
75int(1)
76int(1)
77int(1)
78int(1)
79int(1)
80===DONE===
81