1--TEST--
2Test natcasesort() function : usage variations - different numeric types
3--SKIPIF--
4<?php
5if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only");
6?>
7--FILE--
8<?php
9/* Prototype  : bool natcasesort(array &$array_arg)
10 * Description: Sort an array using case-insensitive natural sort
11 * Source code: ext/standard/array.c
12 */
13
14/*
15 * Pass arrays of numeric data to test how natcasesort re-orders the array
16 */
17
18echo "*** Testing natcasesort() : usage variation ***\n";
19
20$inputs = array (
21
22  // negative/positive integers array
23  array(11, -11, 21, -21, 31, -31, 0, 41, -41),
24
25  // float value array
26  array(10.5, -10.5, 10.5e2, 10.6E-2, .5, .01, -.1),
27
28  // mixed value array
29  array(.0001, .0021, -.01, -1, 0, .09, 2, -.9, 10.6E-2, -10.6E-2, 33),
30
31  // array values contains minimum and maximum ranges
32  array(2147483647, 2147483648, -2147483647, -2147483648, -0, 0, -2147483649)
33);
34
35$iterator = 1;
36foreach ($inputs as $array_arg) {
37	echo "\n-- Iteration $iterator --\n";
38	var_dump(natcasesort($array_arg));
39	var_dump($array_arg);
40}
41
42echo "Done";
43?>
44
45--EXPECTF--
46*** Testing natcasesort() : usage variation ***
47
48-- Iteration 1 --
49bool(true)
50array(9) {
51  [1]=>
52  int(-11)
53  [3]=>
54  int(-21)
55  [5]=>
56  int(-31)
57  [8]=>
58  int(-41)
59  [6]=>
60  int(0)
61  [0]=>
62  int(11)
63  [2]=>
64  int(21)
65  [4]=>
66  int(31)
67  [7]=>
68  int(41)
69}
70
71-- Iteration 1 --
72bool(true)
73array(7) {
74  [6]=>
75  float(-0.1)
76  [1]=>
77  float(-10.5)
78  [5]=>
79  float(0.01)
80  [4]=>
81  float(0.5)
82  [3]=>
83  float(0.106)
84  [0]=>
85  float(10.5)
86  [2]=>
87  float(1050)
88}
89
90-- Iteration 1 --
91bool(true)
92array(11) {
93  [2]=>
94  float(-0.01)
95  [7]=>
96  float(-0.9)
97  [9]=>
98  float(-0.106)
99  [3]=>
100  int(-1)
101  [4]=>
102  int(0)
103  [0]=>
104  float(0.0001)
105  [1]=>
106  float(0.0021)
107  [5]=>
108  float(0.09)
109  [8]=>
110  float(0.106)
111  [6]=>
112  int(2)
113  [10]=>
114  int(33)
115}
116
117-- Iteration 1 --
118bool(true)
119array(7) {
120  [2]=>
121  int(-2147483647)
122  [3]=>
123  float(-2147483648)
124  [6]=>
125  float(-2147483649)
126  [5]=>
127  int(0)
128  [4]=>
129  int(0)
130  [0]=>
131  int(2147483647)
132  [1]=>
133  float(2147483648)
134}
135Done