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--EXPECT-- 45*** Testing natcasesort() : usage variation *** 46 47-- Iteration 1 -- 48bool(true) 49array(9) { 50 [1]=> 51 int(-11) 52 [3]=> 53 int(-21) 54 [5]=> 55 int(-31) 56 [8]=> 57 int(-41) 58 [6]=> 59 int(0) 60 [0]=> 61 int(11) 62 [2]=> 63 int(21) 64 [4]=> 65 int(31) 66 [7]=> 67 int(41) 68} 69 70-- Iteration 1 -- 71bool(true) 72array(7) { 73 [6]=> 74 float(-0.1) 75 [1]=> 76 float(-10.5) 77 [5]=> 78 float(0.01) 79 [4]=> 80 float(0.5) 81 [3]=> 82 float(0.106) 83 [0]=> 84 float(10.5) 85 [2]=> 86 float(1050) 87} 88 89-- Iteration 1 -- 90bool(true) 91array(11) { 92 [2]=> 93 float(-0.01) 94 [7]=> 95 float(-0.9) 96 [9]=> 97 float(-0.106) 98 [3]=> 99 int(-1) 100 [4]=> 101 int(0) 102 [0]=> 103 float(0.0001) 104 [1]=> 105 float(0.0021) 106 [5]=> 107 float(0.09) 108 [8]=> 109 float(0.106) 110 [6]=> 111 int(2) 112 [10]=> 113 int(33) 114} 115 116-- Iteration 1 -- 117bool(true) 118array(7) { 119 [2]=> 120 int(-2147483647) 121 [3]=> 122 float(-2147483648) 123 [6]=> 124 float(-2147483649) 125 [4]=> 126 int(0) 127 [5]=> 128 int(0) 129 [0]=> 130 int(2147483647) 131 [1]=> 132 float(2147483648) 133} 134Done 135