mirror of
https://github.com/php/php-src.git
synced 2025-01-08 20:17:28 +08:00
New testcases for sort() function
This commit is contained in:
parent
49785e26ae
commit
c9b73bf23d
134
ext/standard/tests/array/sort_basic.phpt
Normal file
134
ext/standard/tests/array/sort_basic.phpt
Normal file
@ -0,0 +1,134 @@
|
||||
--TEST--
|
||||
Test sort() function : basic functionality
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : bool sort ( array &$array [, int $sort_flags] )
|
||||
* Description: This function sorts an array.
|
||||
Elements will be arranged from lowest to highest when this function has completed.
|
||||
* Source code: ext/standard/array.c
|
||||
*/
|
||||
|
||||
/*
|
||||
* Testing sort() by providing arrays with default keys and assoc arrays
|
||||
* to check the basic functionality with following flag values.
|
||||
* flag value as defualt
|
||||
* SORT_REGULAR - compare items normally
|
||||
* SORT_NUMERIC - compare items numerically
|
||||
* SORT_STRING - compare items as strings
|
||||
*/
|
||||
|
||||
echo "*** Testing sort() : basic functionality ***\n";
|
||||
|
||||
// associative array containing unsorted string values
|
||||
$unsorted_strings = array( "l" => "lemon", "o" => "orange", "b" => "banana" );
|
||||
|
||||
// array with default keys containing unsorted numeric values
|
||||
$unsorted_numerics = array( 100, 33, 555, 22 );
|
||||
|
||||
echo "\n-- Testing sort() by supplying string array, 'flag' value is defualt --\n";
|
||||
$temp_array = $unsorted_strings;
|
||||
var_dump( sort($temp_array) ); // expecting : bool(true)
|
||||
var_dump( $temp_array);
|
||||
|
||||
echo "\n-- Testing sort() by supplying numeric array, 'flag' value is defualt --\n";
|
||||
$temp_array = $unsorted_numerics;
|
||||
var_dump( sort($temp_array) ); // expecting : bool(true)
|
||||
var_dump( $temp_array);
|
||||
|
||||
echo "\n-- Testing sort() by supplying string array, 'flag' = SORT_REGULAR --\n";
|
||||
$temp_array = $unsorted_strings;
|
||||
var_dump( sort($temp_array, SORT_REGULAR) ); // expecting : bool(true)
|
||||
var_dump( $temp_array);
|
||||
|
||||
echo "\n-- Testing sort() by supplying numeric array, 'flag' = SORT_REGULAR --\n";
|
||||
$temp_array = $unsorted_numerics;
|
||||
var_dump( sort($temp_array, SORT_REGULAR) ); // expecting : bool(true)
|
||||
var_dump( $temp_array);
|
||||
|
||||
echo "\n-- Testing sort() by supplying string array, 'flag' = SORT_STRING --\n";
|
||||
$temp_array = $unsorted_strings;
|
||||
var_dump( sort($temp_array, SORT_STRING) ); // expecting : bool(true)
|
||||
var_dump( $temp_array);
|
||||
|
||||
echo "\n-- Testing sort() by supplying numeric array, 'flag' = SORT_NUMERIC --\n";
|
||||
$temp_array = $unsorted_numerics;
|
||||
var_dump( sort($temp_array, SORT_NUMERIC) ); // expecting : bool(true)
|
||||
var_dump( $temp_array);
|
||||
|
||||
echo "Done\n";
|
||||
?>
|
||||
--EXPECTF--
|
||||
*** Testing sort() : basic functionality ***
|
||||
|
||||
-- Testing sort() by supplying string array, 'flag' value is defualt --
|
||||
bool(true)
|
||||
array(3) {
|
||||
[0]=>
|
||||
string(6) "banana"
|
||||
[1]=>
|
||||
string(5) "lemon"
|
||||
[2]=>
|
||||
string(6) "orange"
|
||||
}
|
||||
|
||||
-- Testing sort() by supplying numeric array, 'flag' value is defualt --
|
||||
bool(true)
|
||||
array(4) {
|
||||
[0]=>
|
||||
int(22)
|
||||
[1]=>
|
||||
int(33)
|
||||
[2]=>
|
||||
int(100)
|
||||
[3]=>
|
||||
int(555)
|
||||
}
|
||||
|
||||
-- Testing sort() by supplying string array, 'flag' = SORT_REGULAR --
|
||||
bool(true)
|
||||
array(3) {
|
||||
[0]=>
|
||||
string(6) "banana"
|
||||
[1]=>
|
||||
string(5) "lemon"
|
||||
[2]=>
|
||||
string(6) "orange"
|
||||
}
|
||||
|
||||
-- Testing sort() by supplying numeric array, 'flag' = SORT_REGULAR --
|
||||
bool(true)
|
||||
array(4) {
|
||||
[0]=>
|
||||
int(22)
|
||||
[1]=>
|
||||
int(33)
|
||||
[2]=>
|
||||
int(100)
|
||||
[3]=>
|
||||
int(555)
|
||||
}
|
||||
|
||||
-- Testing sort() by supplying string array, 'flag' = SORT_STRING --
|
||||
bool(true)
|
||||
array(3) {
|
||||
[0]=>
|
||||
string(6) "banana"
|
||||
[1]=>
|
||||
string(5) "lemon"
|
||||
[2]=>
|
||||
string(6) "orange"
|
||||
}
|
||||
|
||||
-- Testing sort() by supplying numeric array, 'flag' = SORT_NUMERIC --
|
||||
bool(true)
|
||||
array(4) {
|
||||
[0]=>
|
||||
int(22)
|
||||
[1]=>
|
||||
int(33)
|
||||
[2]=>
|
||||
int(100)
|
||||
[3]=>
|
||||
int(555)
|
||||
}
|
||||
Done
|
79
ext/standard/tests/array/sort_error.phpt
Normal file
79
ext/standard/tests/array/sort_error.phpt
Normal file
@ -0,0 +1,79 @@
|
||||
--TEST--
|
||||
Test sort() function : error conditions
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : bool sort(array &array_arg [, int sort_flags])
|
||||
* Description: Sort an array
|
||||
* Source code: ext/standard/array.c
|
||||
*/
|
||||
|
||||
/*
|
||||
* Testing sort() function with all possible error conditions
|
||||
*/
|
||||
|
||||
echo "*** Testing sort() : error conditions ***\n";
|
||||
|
||||
// zero arguments
|
||||
echo "\n-- Testing sort() function with Zero arguments --\n";
|
||||
var_dump( sort() );
|
||||
|
||||
//Test sort with more than the expected number of arguments
|
||||
echo "\n-- Testing sort() function with more than expected no. of arguments --\n";
|
||||
$array_arg = array(1, 2);
|
||||
$flag_value = array("SORT_REGULAR" => SORT_REGULAR, "SORT_STRING" => SORT_STRING, "SORT_NUMERIC" => SORT_NUMERIC);
|
||||
$extra_arg = 10;
|
||||
|
||||
// loop through $flag_value array and setting all possible flag values
|
||||
foreach($flag_value as $key => $flag){
|
||||
echo "\nSort flag = $key\n";
|
||||
var_dump( sort($array_arg,$flag, $extra_arg) );
|
||||
|
||||
// dump the input array to ensure that it wasn't changed
|
||||
var_dump($array_arg);
|
||||
}
|
||||
|
||||
echo "Done";
|
||||
?>
|
||||
--EXPECTF--
|
||||
*** Testing sort() : error conditions ***
|
||||
|
||||
-- Testing sort() function with Zero arguments --
|
||||
|
||||
Warning: sort() expects at least 1 parameter, 0 given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- Testing sort() function with more than expected no. of arguments --
|
||||
|
||||
Sort flag = SORT_REGULAR
|
||||
|
||||
Warning: sort() expects at most 2 parameters, 3 given in %s on line %d
|
||||
bool(false)
|
||||
array(2) {
|
||||
[0]=>
|
||||
int(1)
|
||||
[1]=>
|
||||
int(2)
|
||||
}
|
||||
|
||||
Sort flag = SORT_STRING
|
||||
|
||||
Warning: sort() expects at most 2 parameters, 3 given in %s on line %d
|
||||
bool(false)
|
||||
array(2) {
|
||||
[0]=>
|
||||
int(1)
|
||||
[1]=>
|
||||
int(2)
|
||||
}
|
||||
|
||||
Sort flag = SORT_NUMERIC
|
||||
|
||||
Warning: sort() expects at most 2 parameters, 3 given in %s on line %d
|
||||
bool(false)
|
||||
array(2) {
|
||||
[0]=>
|
||||
int(1)
|
||||
[1]=>
|
||||
int(2)
|
||||
}
|
||||
Done
|
242
ext/standard/tests/array/sort_object1.phpt
Normal file
242
ext/standard/tests/array/sort_object1.phpt
Normal file
@ -0,0 +1,242 @@
|
||||
--TEST--
|
||||
Test sort() function : object functionality - sorting objects, 'sort_flags' as default/SORT_REGULAR
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : bool sort ( array &$array [, int $sort_flags] )
|
||||
* Description: This function sorts an array.
|
||||
Elements will be arranged from lowest to highest when this function has completed.
|
||||
* Source code: ext/standard/array.c
|
||||
*/
|
||||
/*
|
||||
* testing sort() by providing integer/string object arrays with flag values are defualt, SORT_REGULAR
|
||||
*/
|
||||
|
||||
echo "*** Testing sort() : object functionality ***\n";
|
||||
|
||||
// class declaration for integer objects
|
||||
class for_integer_sort
|
||||
{
|
||||
public $class_value;
|
||||
// initializing object member value
|
||||
function __construct($value){
|
||||
$this->class_value = $value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// class declaration for string objects
|
||||
class for_string_sort
|
||||
{
|
||||
public $class_value;
|
||||
// initializing object member value
|
||||
function __construct($value){
|
||||
$this->class_value = $value;
|
||||
}
|
||||
|
||||
// return string value
|
||||
function __tostring() {
|
||||
return (string)$this->value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// array of integer objects
|
||||
$unsorted_int_obj = array(
|
||||
new for_integer_sort(11), new for_integer_sort(66),
|
||||
new for_integer_sort(23), new for_integer_sort(-5),
|
||||
new for_integer_sort(0.001), new for_integer_sort(0)
|
||||
);
|
||||
|
||||
// array of string objects
|
||||
$unsorted_str_obj = array (
|
||||
new for_string_sort("axx"), new for_string_sort("t"),
|
||||
new for_string_sort("w"), new for_string_sort("py"),
|
||||
new for_string_sort("apple"), new for_string_sort("Orange"),
|
||||
new for_string_sort("Lemon"), new for_string_sort("aPPle")
|
||||
);
|
||||
|
||||
|
||||
echo "\n-- Testing sort() by supplying various object arrays, 'flag' value is defualt --\n";
|
||||
|
||||
// testing sort() function by supplying integer object array, flag value is defualt
|
||||
$temp_array = $unsorted_int_obj;
|
||||
var_dump(sort($temp_array) );
|
||||
var_dump($temp_array);
|
||||
|
||||
// testing sort() function by supplying string object array, flag value is defualt
|
||||
$temp_array = $unsorted_str_obj;
|
||||
var_dump(sort($temp_array) );
|
||||
var_dump($temp_array);
|
||||
|
||||
echo "\n-- Testing sort() by supplying various object arrays, 'flag' value is SORT_REGULAR --\n";
|
||||
// testing sort() function by supplying integer object array, flag value = SORT_REGULAR
|
||||
$temp_array = $unsorted_int_obj;
|
||||
var_dump(sort($temp_array, SORT_REGULAR) );
|
||||
var_dump($temp_array);
|
||||
|
||||
// testing sort() function by supplying string object array, flag value = SORT_REGULAR
|
||||
$temp_array = $unsorted_str_obj;
|
||||
var_dump(sort($temp_array, SORT_REGULAR) );
|
||||
var_dump($temp_array);
|
||||
|
||||
echo "Done\n";
|
||||
?>
|
||||
--EXPECTF--
|
||||
*** Testing sort() : object functionality ***
|
||||
|
||||
-- Testing sort() by supplying various object arrays, 'flag' value is defualt --
|
||||
bool(true)
|
||||
array(6) {
|
||||
[0]=>
|
||||
object(for_integer_sort)#%d (1) {
|
||||
["class_value"]=>
|
||||
int(-5)
|
||||
}
|
||||
[1]=>
|
||||
object(for_integer_sort)#%d (1) {
|
||||
["class_value"]=>
|
||||
int(0)
|
||||
}
|
||||
[2]=>
|
||||
object(for_integer_sort)#%d (1) {
|
||||
["class_value"]=>
|
||||
float(0.001)
|
||||
}
|
||||
[3]=>
|
||||
object(for_integer_sort)#%d (1) {
|
||||
["class_value"]=>
|
||||
int(11)
|
||||
}
|
||||
[4]=>
|
||||
object(for_integer_sort)#%d (1) {
|
||||
["class_value"]=>
|
||||
int(23)
|
||||
}
|
||||
[5]=>
|
||||
object(for_integer_sort)#%d (1) {
|
||||
["class_value"]=>
|
||||
int(66)
|
||||
}
|
||||
}
|
||||
bool(true)
|
||||
array(8) {
|
||||
[0]=>
|
||||
object(for_string_sort)#%d (1) {
|
||||
["class_value"]=>
|
||||
string(5) "Lemon"
|
||||
}
|
||||
[1]=>
|
||||
object(for_string_sort)#%d (1) {
|
||||
["class_value"]=>
|
||||
string(6) "Orange"
|
||||
}
|
||||
[2]=>
|
||||
object(for_string_sort)#%d (1) {
|
||||
["class_value"]=>
|
||||
string(5) "aPPle"
|
||||
}
|
||||
[3]=>
|
||||
object(for_string_sort)#%d (1) {
|
||||
["class_value"]=>
|
||||
string(5) "apple"
|
||||
}
|
||||
[4]=>
|
||||
object(for_string_sort)#%d (1) {
|
||||
["class_value"]=>
|
||||
string(3) "axx"
|
||||
}
|
||||
[5]=>
|
||||
object(for_string_sort)#%d (1) {
|
||||
["class_value"]=>
|
||||
string(2) "py"
|
||||
}
|
||||
[6]=>
|
||||
object(for_string_sort)#%d (1) {
|
||||
["class_value"]=>
|
||||
string(1) "t"
|
||||
}
|
||||
[7]=>
|
||||
object(for_string_sort)#%d (1) {
|
||||
["class_value"]=>
|
||||
string(1) "w"
|
||||
}
|
||||
}
|
||||
|
||||
-- Testing sort() by supplying various object arrays, 'flag' value is SORT_REGULAR --
|
||||
bool(true)
|
||||
array(6) {
|
||||
[0]=>
|
||||
object(for_integer_sort)#%d (1) {
|
||||
["class_value"]=>
|
||||
int(-5)
|
||||
}
|
||||
[1]=>
|
||||
object(for_integer_sort)#%d (1) {
|
||||
["class_value"]=>
|
||||
int(0)
|
||||
}
|
||||
[2]=>
|
||||
object(for_integer_sort)#%d (1) {
|
||||
["class_value"]=>
|
||||
float(0.001)
|
||||
}
|
||||
[3]=>
|
||||
object(for_integer_sort)#%d (1) {
|
||||
["class_value"]=>
|
||||
int(11)
|
||||
}
|
||||
[4]=>
|
||||
object(for_integer_sort)#%d (1) {
|
||||
["class_value"]=>
|
||||
int(23)
|
||||
}
|
||||
[5]=>
|
||||
object(for_integer_sort)#%d (1) {
|
||||
["class_value"]=>
|
||||
int(66)
|
||||
}
|
||||
}
|
||||
bool(true)
|
||||
array(8) {
|
||||
[0]=>
|
||||
object(for_string_sort)#%d (1) {
|
||||
["class_value"]=>
|
||||
string(5) "Lemon"
|
||||
}
|
||||
[1]=>
|
||||
object(for_string_sort)#%d (1) {
|
||||
["class_value"]=>
|
||||
string(6) "Orange"
|
||||
}
|
||||
[2]=>
|
||||
object(for_string_sort)#%d (1) {
|
||||
["class_value"]=>
|
||||
string(5) "aPPle"
|
||||
}
|
||||
[3]=>
|
||||
object(for_string_sort)#%d (1) {
|
||||
["class_value"]=>
|
||||
string(5) "apple"
|
||||
}
|
||||
[4]=>
|
||||
object(for_string_sort)#%d (1) {
|
||||
["class_value"]=>
|
||||
string(3) "axx"
|
||||
}
|
||||
[5]=>
|
||||
object(for_string_sort)#%d (1) {
|
||||
["class_value"]=>
|
||||
string(2) "py"
|
||||
}
|
||||
[6]=>
|
||||
object(for_string_sort)#%d (1) {
|
||||
["class_value"]=>
|
||||
string(1) "t"
|
||||
}
|
||||
[7]=>
|
||||
object(for_string_sort)#%d (1) {
|
||||
["class_value"]=>
|
||||
string(1) "w"
|
||||
}
|
||||
}
|
||||
Done
|
256
ext/standard/tests/array/sort_object2.phpt
Normal file
256
ext/standard/tests/array/sort_object2.phpt
Normal file
@ -0,0 +1,256 @@
|
||||
--TEST--
|
||||
Test sort() function : object functionality - sorting objects with diff. accessiblity of member vars
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : bool sort ( array &$array [, int $sort_flags] )
|
||||
* Description: This function sorts an array.
|
||||
Elements will be arranged from lowest to highest when this function has completed.
|
||||
* Source code: ext/standard/array.c
|
||||
*/
|
||||
|
||||
/*
|
||||
* testing sort() by providing integer/string object arrays with flag values are defualt, SORT_REGULAR
|
||||
*/
|
||||
|
||||
echo "*** Testing sort() : object functionality ***\n";
|
||||
|
||||
// class declaration for integer objects
|
||||
class for_integer_sort
|
||||
{
|
||||
public $public_class_value;
|
||||
private $private_class_value;
|
||||
protected $protected_class_value;
|
||||
|
||||
// initializing object member value
|
||||
function __construct($value1, $value2,$value3){
|
||||
$this->public_class_value = $value1;
|
||||
$this->private_class_value = $value2;
|
||||
$this->protected_class_value = $value3;
|
||||
}
|
||||
}
|
||||
|
||||
// class declaration for string objects
|
||||
class for_string_sort
|
||||
{
|
||||
public $public_class_value;
|
||||
private $private_class_value;
|
||||
protected $protected_class_value;
|
||||
// initializing object member value
|
||||
function __construct($value1, $value2,$value3){
|
||||
$this->public_class_value = $value1;
|
||||
$this->private_class_value = $value2;
|
||||
$this->protected_class_value = $value3;
|
||||
}
|
||||
|
||||
// return string value
|
||||
function __tostring() {
|
||||
return (string)$this->value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// array of integer objects
|
||||
$unsorted_int_obj = array(
|
||||
new for_integer_sort(11,33,30),
|
||||
new for_integer_sort(66,44,4),
|
||||
new for_integer_sort(-88,-5,5),
|
||||
new for_integer_sort(0.001,99.5,0.1)
|
||||
);
|
||||
|
||||
// array of string objects
|
||||
$unsorted_str_obj = array (
|
||||
new for_string_sort("axx","AXX","ass"),
|
||||
new for_string_sort("t","eee","abb"),
|
||||
new for_string_sort("w","W", "c"),
|
||||
new for_string_sort("py","PY", "pt"),
|
||||
);
|
||||
|
||||
|
||||
echo "\n-- Testing sort() by supplying various object arrays, 'flag' value is defualt --\n";
|
||||
|
||||
// testing sort() function by supplying integer object array, flag value is defualt
|
||||
$temp_array = $unsorted_int_obj;
|
||||
var_dump(sort($temp_array) );
|
||||
var_dump($temp_array);
|
||||
|
||||
// testing sort() function by supplying string object array, flag value is defualt
|
||||
$temp_array = $unsorted_str_obj;
|
||||
var_dump(sort($temp_array) );
|
||||
var_dump($temp_array);
|
||||
|
||||
echo "\n-- Testing sort() by supplying various object arrays, 'flag' value is SORT_REGULAR --\n";
|
||||
// testing sort() function by supplying integer object array, flag value = SORT_REGULAR
|
||||
$temp_array = $unsorted_int_obj;
|
||||
var_dump(sort($temp_array, SORT_REGULAR) );
|
||||
var_dump($temp_array);
|
||||
|
||||
// testing sort() function by supplying string object array, flag value = SORT_REGULAR
|
||||
$temp_array = $unsorted_str_obj;
|
||||
var_dump(sort($temp_array, SORT_REGULAR) );
|
||||
var_dump($temp_array);
|
||||
|
||||
echo "Done\n";
|
||||
?>
|
||||
--EXPECTF--
|
||||
*** Testing sort() : object functionality ***
|
||||
|
||||
-- Testing sort() by supplying various object arrays, 'flag' value is defualt --
|
||||
bool(true)
|
||||
array(4) {
|
||||
[0]=>
|
||||
object(for_integer_sort)#%d (3) {
|
||||
["public_class_value"]=>
|
||||
int(-88)
|
||||
["private_class_value":"for_integer_sort":private]=>
|
||||
int(-5)
|
||||
["protected_class_value":protected]=>
|
||||
int(5)
|
||||
}
|
||||
[1]=>
|
||||
object(for_integer_sort)#%d (3) {
|
||||
["public_class_value"]=>
|
||||
float(0.001)
|
||||
["private_class_value":"for_integer_sort":private]=>
|
||||
float(99.5)
|
||||
["protected_class_value":protected]=>
|
||||
float(0.1)
|
||||
}
|
||||
[2]=>
|
||||
object(for_integer_sort)#%d (3) {
|
||||
["public_class_value"]=>
|
||||
int(11)
|
||||
["private_class_value":"for_integer_sort":private]=>
|
||||
int(33)
|
||||
["protected_class_value":protected]=>
|
||||
int(30)
|
||||
}
|
||||
[3]=>
|
||||
object(for_integer_sort)#%d (3) {
|
||||
["public_class_value"]=>
|
||||
int(66)
|
||||
["private_class_value":"for_integer_sort":private]=>
|
||||
int(44)
|
||||
["protected_class_value":protected]=>
|
||||
int(4)
|
||||
}
|
||||
}
|
||||
bool(true)
|
||||
array(4) {
|
||||
[0]=>
|
||||
object(for_string_sort)#%d (3) {
|
||||
["public_class_value"]=>
|
||||
string(3) "axx"
|
||||
["private_class_value":"for_string_sort":private]=>
|
||||
string(3) "AXX"
|
||||
["protected_class_value":protected]=>
|
||||
string(3) "ass"
|
||||
}
|
||||
[1]=>
|
||||
object(for_string_sort)#%d (3) {
|
||||
["public_class_value"]=>
|
||||
string(2) "py"
|
||||
["private_class_value":"for_string_sort":private]=>
|
||||
string(2) "PY"
|
||||
["protected_class_value":protected]=>
|
||||
string(2) "pt"
|
||||
}
|
||||
[2]=>
|
||||
object(for_string_sort)#%d (3) {
|
||||
["public_class_value"]=>
|
||||
string(1) "t"
|
||||
["private_class_value":"for_string_sort":private]=>
|
||||
string(3) "eee"
|
||||
["protected_class_value":protected]=>
|
||||
string(3) "abb"
|
||||
}
|
||||
[3]=>
|
||||
object(for_string_sort)#%d (3) {
|
||||
["public_class_value"]=>
|
||||
string(1) "w"
|
||||
["private_class_value":"for_string_sort":private]=>
|
||||
string(1) "W"
|
||||
["protected_class_value":protected]=>
|
||||
string(1) "c"
|
||||
}
|
||||
}
|
||||
|
||||
-- Testing sort() by supplying various object arrays, 'flag' value is SORT_REGULAR --
|
||||
bool(true)
|
||||
array(4) {
|
||||
[0]=>
|
||||
object(for_integer_sort)#%d (3) {
|
||||
["public_class_value"]=>
|
||||
int(-88)
|
||||
["private_class_value":"for_integer_sort":private]=>
|
||||
int(-5)
|
||||
["protected_class_value":protected]=>
|
||||
int(5)
|
||||
}
|
||||
[1]=>
|
||||
object(for_integer_sort)#%d (3) {
|
||||
["public_class_value"]=>
|
||||
float(0.001)
|
||||
["private_class_value":"for_integer_sort":private]=>
|
||||
float(99.5)
|
||||
["protected_class_value":protected]=>
|
||||
float(0.1)
|
||||
}
|
||||
[2]=>
|
||||
object(for_integer_sort)#%d (3) {
|
||||
["public_class_value"]=>
|
||||
int(11)
|
||||
["private_class_value":"for_integer_sort":private]=>
|
||||
int(33)
|
||||
["protected_class_value":protected]=>
|
||||
int(30)
|
||||
}
|
||||
[3]=>
|
||||
object(for_integer_sort)#%d (3) {
|
||||
["public_class_value"]=>
|
||||
int(66)
|
||||
["private_class_value":"for_integer_sort":private]=>
|
||||
int(44)
|
||||
["protected_class_value":protected]=>
|
||||
int(4)
|
||||
}
|
||||
}
|
||||
bool(true)
|
||||
array(4) {
|
||||
[0]=>
|
||||
object(for_string_sort)#%d (3) {
|
||||
["public_class_value"]=>
|
||||
string(3) "axx"
|
||||
["private_class_value":"for_string_sort":private]=>
|
||||
string(3) "AXX"
|
||||
["protected_class_value":protected]=>
|
||||
string(3) "ass"
|
||||
}
|
||||
[1]=>
|
||||
object(for_string_sort)#%d (3) {
|
||||
["public_class_value"]=>
|
||||
string(2) "py"
|
||||
["private_class_value":"for_string_sort":private]=>
|
||||
string(2) "PY"
|
||||
["protected_class_value":protected]=>
|
||||
string(2) "pt"
|
||||
}
|
||||
[2]=>
|
||||
object(for_string_sort)#%d (3) {
|
||||
["public_class_value"]=>
|
||||
string(1) "t"
|
||||
["private_class_value":"for_string_sort":private]=>
|
||||
string(3) "eee"
|
||||
["protected_class_value":protected]=>
|
||||
string(3) "abb"
|
||||
}
|
||||
[3]=>
|
||||
object(for_string_sort)#%d (3) {
|
||||
["public_class_value"]=>
|
||||
string(1) "w"
|
||||
["private_class_value":"for_string_sort":private]=>
|
||||
string(1) "W"
|
||||
["protected_class_value":protected]=>
|
||||
string(1) "c"
|
||||
}
|
||||
}
|
||||
Done
|
398
ext/standard/tests/array/sort_variation1.phpt
Normal file
398
ext/standard/tests/array/sort_variation1.phpt
Normal file
@ -0,0 +1,398 @@
|
||||
--TEST--
|
||||
Test sort() function : usage variations - unexpected values for 'array_arg' argument
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : bool sort(array &array_arg [, int $sort_flags])
|
||||
* Description: Sort an array
|
||||
* Source code: ext/standard/array.c
|
||||
*/
|
||||
|
||||
/*
|
||||
* testing sort() by providing different unexpected values for array argument
|
||||
* with following flag values.
|
||||
* 1. flag value as defualt
|
||||
* 2. SORT_REGULAR - compare items normally
|
||||
* 3. SORT_NUMERIC - compare items numerically
|
||||
* 4. SORT_STRING - compare items as strings
|
||||
*/
|
||||
|
||||
echo "*** Testing sort() : usage variations ***\n";
|
||||
|
||||
//get an unset variable
|
||||
$unset_var = 10;
|
||||
unset ($unset_var);
|
||||
|
||||
// resource variable
|
||||
$fp = fopen(__FILE__, "r");
|
||||
|
||||
//array of values to iterate over
|
||||
$unexpected_values = array (
|
||||
|
||||
// int data
|
||||
/*1*/ 0,
|
||||
1,
|
||||
12345,
|
||||
-2345,
|
||||
|
||||
// float data
|
||||
/*5*/ 10.5,
|
||||
-10.5,
|
||||
10.5e3,
|
||||
10.6E-2,
|
||||
.5,
|
||||
|
||||
// null data
|
||||
/*10*/ NULL,
|
||||
null,
|
||||
|
||||
// boolean data
|
||||
/*12*/ true,
|
||||
false,
|
||||
TRUE,
|
||||
FALSE,
|
||||
|
||||
// empty data
|
||||
/*16*/ "",
|
||||
'',
|
||||
|
||||
// string data
|
||||
/*18*/ "string",
|
||||
'string',
|
||||
|
||||
// object data
|
||||
/*20*/ new stdclass(),
|
||||
|
||||
// undefined data
|
||||
/*21*/ @undefined_var,
|
||||
|
||||
// unset data
|
||||
/*22*/ @unset_var,
|
||||
|
||||
// resource variable
|
||||
/*23*/ $fp
|
||||
);
|
||||
|
||||
// loop though each element of the array and check the working of sort()
|
||||
// when $array arugment is supplied with different values from $unexpected_values
|
||||
echo "\n-- Testing sort() by supplying different unexpected values for 'array' argument --\n";
|
||||
echo "\n-- Flag values are defualt, SORT_REGULAR, SORT_NUMERIC, SORT_STRING --\n";
|
||||
|
||||
$counter = 1;
|
||||
for($index = 0; $index < count($unexpected_values); $index ++) {
|
||||
echo "-- Iteration $counter --\n";
|
||||
$value = $unexpected_values [$index];
|
||||
var_dump( sort($value) ); // expecting : bool(false)
|
||||
var_dump( sort($value, SORT_REGULAR) ); // expecting : bool(false)
|
||||
var_dump( sort($value, SORT_NUMERIC) ); // expecting : bool(false)
|
||||
var_dump( sort($value, SORT_STRING) ); // expecting : bool(false)
|
||||
$counter++;
|
||||
}
|
||||
|
||||
echo "Done";
|
||||
?>
|
||||
--EXPECTF--
|
||||
*** Testing sort() : usage variations ***
|
||||
|
||||
-- Testing sort() by supplying different unexpected values for 'array' argument --
|
||||
|
||||
-- Flag values are defualt, SORT_REGULAR, SORT_NUMERIC, SORT_STRING --
|
||||
-- Iteration 1 --
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, integer given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, integer given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, integer given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, integer given in %s on line %d
|
||||
bool(false)
|
||||
-- Iteration 2 --
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, integer given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, integer given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, integer given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, integer given in %s on line %d
|
||||
bool(false)
|
||||
-- Iteration 3 --
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, integer given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, integer given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, integer given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, integer given in %s on line %d
|
||||
bool(false)
|
||||
-- Iteration 4 --
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, integer given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, integer given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, integer given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, integer given in %s on line %d
|
||||
bool(false)
|
||||
-- Iteration 5 --
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, double given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, double given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, double given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, double given in %s on line %d
|
||||
bool(false)
|
||||
-- Iteration 6 --
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, double given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, double given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, double given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, double given in %s on line %d
|
||||
bool(false)
|
||||
-- Iteration 7 --
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, double given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, double given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, double given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, double given in %s on line %d
|
||||
bool(false)
|
||||
-- Iteration 8 --
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, double given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, double given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, double given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, double given in %s on line %d
|
||||
bool(false)
|
||||
-- Iteration 9 --
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, double given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, double given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, double given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, double given in %s on line %d
|
||||
bool(false)
|
||||
-- Iteration 10 --
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, null given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, null given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, null given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, null given in %s on line %d
|
||||
bool(false)
|
||||
-- Iteration 11 --
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, null given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, null given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, null given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, null given in %s on line %d
|
||||
bool(false)
|
||||
-- Iteration 12 --
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, boolean given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, boolean given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, boolean given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, boolean given in %s on line %d
|
||||
bool(false)
|
||||
-- Iteration 13 --
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, boolean given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, boolean given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, boolean given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, boolean given in %s on line %d
|
||||
bool(false)
|
||||
-- Iteration 14 --
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, boolean given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, boolean given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, boolean given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, boolean given in %s on line %d
|
||||
bool(false)
|
||||
-- Iteration 15 --
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, boolean given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, boolean given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, boolean given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, boolean given in %s on line %d
|
||||
bool(false)
|
||||
-- Iteration 16 --
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, string given in %s on line %d
|
||||
bool(false)
|
||||
-- Iteration 17 --
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, string given in %s on line %d
|
||||
bool(false)
|
||||
-- Iteration 18 --
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, string given in %s on line %d
|
||||
bool(false)
|
||||
-- Iteration 19 --
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, string given in %s on line %d
|
||||
bool(false)
|
||||
-- Iteration 20 --
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, object given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, object given in %s on line %d
|
||||
bool(false)
|
||||
-- Iteration 21 --
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, string given in %s on line %d
|
||||
bool(false)
|
||||
-- Iteration 22 --
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, string given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, string given in %s on line %d
|
||||
bool(false)
|
||||
-- Iteration 23 --
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, resource given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, resource given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, resource given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: sort() expects parameter 1 to be array, resource given in %s on line %d
|
||||
bool(false)
|
||||
Done
|
112
ext/standard/tests/array/sort_variation10.phpt
Normal file
112
ext/standard/tests/array/sort_variation10.phpt
Normal file
@ -0,0 +1,112 @@
|
||||
--TEST--
|
||||
Test sort() function : usage variations - sort octal values
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : bool sort ( array &$array [, int $sort_flags] )
|
||||
* Description: This function sorts an array.
|
||||
Elements will be arranged from lowest to highest when this function has completed.
|
||||
* Source code: ext/standard/array.c
|
||||
*/
|
||||
|
||||
/*
|
||||
* testing sort() by providing different octal array for $array argument
|
||||
* with following flag values
|
||||
* 1.flag value as defualt
|
||||
* 2.SORT_REGULAR - compare items normally
|
||||
* 3.SORT_NUMERIC - compare items numerically
|
||||
*/
|
||||
|
||||
echo "*** Testing sort() : usage variations ***\n";
|
||||
|
||||
// an array containing unsorted octal values
|
||||
$unsorted_oct_array = array(01235, 0321, 0345, 066, 0772, 077, -066, -0345, 0);
|
||||
|
||||
echo "\n-- Testing sort() by supplying octal value array, 'flag' value is defualt --\n";
|
||||
$temp_array = $unsorted_oct_array;
|
||||
var_dump(sort($temp_array) ); // expecting : bool(true)
|
||||
var_dump($temp_array);
|
||||
|
||||
echo "\n-- Testing sort() by supplying octal value array, 'flag' value is SORT_REGULAR --\n";
|
||||
$temp_array = $unsorted_oct_array;
|
||||
var_dump(sort($temp_array, SORT_REGULAR) ); // expecting : bool(true)
|
||||
var_dump($temp_array);
|
||||
|
||||
echo "\n-- Testing sort() by supplying octal value array, 'flag' value is SORT_NUMERIC --\n";
|
||||
$temp_array = $unsorted_oct_array;
|
||||
var_dump(sort($temp_array, SORT_NUMERIC) ); // expecting : bool(true)
|
||||
var_dump($temp_array);
|
||||
|
||||
echo "Done\n";
|
||||
?>
|
||||
--EXPECTF--
|
||||
*** Testing sort() : usage variations ***
|
||||
|
||||
-- Testing sort() by supplying octal value array, 'flag' value is defualt --
|
||||
bool(true)
|
||||
array(9) {
|
||||
[0]=>
|
||||
int(-229)
|
||||
[1]=>
|
||||
int(-54)
|
||||
[2]=>
|
||||
int(0)
|
||||
[3]=>
|
||||
int(54)
|
||||
[4]=>
|
||||
int(63)
|
||||
[5]=>
|
||||
int(209)
|
||||
[6]=>
|
||||
int(229)
|
||||
[7]=>
|
||||
int(506)
|
||||
[8]=>
|
||||
int(669)
|
||||
}
|
||||
|
||||
-- Testing sort() by supplying octal value array, 'flag' value is SORT_REGULAR --
|
||||
bool(true)
|
||||
array(9) {
|
||||
[0]=>
|
||||
int(-229)
|
||||
[1]=>
|
||||
int(-54)
|
||||
[2]=>
|
||||
int(0)
|
||||
[3]=>
|
||||
int(54)
|
||||
[4]=>
|
||||
int(63)
|
||||
[5]=>
|
||||
int(209)
|
||||
[6]=>
|
||||
int(229)
|
||||
[7]=>
|
||||
int(506)
|
||||
[8]=>
|
||||
int(669)
|
||||
}
|
||||
|
||||
-- Testing sort() by supplying octal value array, 'flag' value is SORT_NUMERIC --
|
||||
bool(true)
|
||||
array(9) {
|
||||
[0]=>
|
||||
int(-229)
|
||||
[1]=>
|
||||
int(-54)
|
||||
[2]=>
|
||||
int(0)
|
||||
[3]=>
|
||||
int(54)
|
||||
[4]=>
|
||||
int(63)
|
||||
[5]=>
|
||||
int(209)
|
||||
[6]=>
|
||||
int(229)
|
||||
[7]=>
|
||||
int(506)
|
||||
[8]=>
|
||||
int(669)
|
||||
}
|
||||
Done
|
BIN
ext/standard/tests/array/sort_variation11.phpt
Normal file
BIN
ext/standard/tests/array/sort_variation11.phpt
Normal file
Binary file not shown.
311
ext/standard/tests/array/sort_variation2.phpt
Normal file
311
ext/standard/tests/array/sort_variation2.phpt
Normal file
@ -0,0 +1,311 @@
|
||||
--TEST--
|
||||
Test sort() function : usage variations - unexpected values for 'sort_flags' argument
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : bool sort(array &array_arg [, int $sort_flags])
|
||||
* Description: Sort an array
|
||||
* Source code: ext/standard/array.c
|
||||
*/
|
||||
|
||||
/*
|
||||
* Testing sort() by providing different unexpected values for flag argument
|
||||
*/
|
||||
|
||||
echo "*** Testing sort() : usage variations ***\n";
|
||||
|
||||
//get an unset variable
|
||||
$unset_var = 10;
|
||||
unset ($unset_var);
|
||||
|
||||
// resource variable
|
||||
$fp = fopen(__FILE__, "r");
|
||||
|
||||
// temperory array for checking unexpected behavior
|
||||
$unsorted_values = array(10, 2, 45);
|
||||
|
||||
//array of values to iterate over
|
||||
$unexpected_values = array(
|
||||
|
||||
// int data
|
||||
/*1*/ -2345,
|
||||
|
||||
// float data
|
||||
/*2*/ 10.5,
|
||||
-10.5,
|
||||
10.5e2,
|
||||
10.6E-2,
|
||||
.5,
|
||||
|
||||
// null data
|
||||
/*7*/ NULL,
|
||||
null,
|
||||
|
||||
// boolean data
|
||||
/*9*/ true,
|
||||
false,
|
||||
TRUE,
|
||||
FALSE,
|
||||
|
||||
// empty data
|
||||
/*13*/ "",
|
||||
'',
|
||||
|
||||
// string data
|
||||
/*15*/ "string",
|
||||
'string',
|
||||
|
||||
// object data
|
||||
/*16*/ new stdclass(),
|
||||
|
||||
// undefined data
|
||||
/*17*/ @undefined_var,
|
||||
|
||||
// unset data
|
||||
/*18*/ @unset_var,
|
||||
|
||||
// resource variable
|
||||
/*19*/ $fp
|
||||
|
||||
);
|
||||
|
||||
// loop though each element of the array and check the working of sort()
|
||||
// when $flag arugment is supplied with different values
|
||||
echo "\n-- Testing sort() by supplying different unexpected values for 'flag' argument --\n";
|
||||
|
||||
$counter = 1;
|
||||
for($index = 0; $index < count($unexpected_values); $index ++) {
|
||||
echo "-- Iteration $counter --\n";
|
||||
|
||||
// sort the array, retain a temp. copy of input array for next iteration
|
||||
$value = $unexpected_values [$index];
|
||||
$temp_array = $unsorted_values;
|
||||
var_dump( sort($temp_array, $value) );
|
||||
|
||||
//dump the sorted array
|
||||
var_dump($temp_array);
|
||||
$counter++;
|
||||
}
|
||||
|
||||
echo "Done";
|
||||
?>
|
||||
--EXPECTF--
|
||||
*** Testing sort() : usage variations ***
|
||||
|
||||
-- Testing sort() by supplying different unexpected values for 'flag' argument --
|
||||
-- Iteration 1 --
|
||||
bool(true)
|
||||
array(3) {
|
||||
[0]=>
|
||||
int(2)
|
||||
[1]=>
|
||||
int(10)
|
||||
[2]=>
|
||||
int(45)
|
||||
}
|
||||
-- Iteration 2 --
|
||||
bool(true)
|
||||
array(3) {
|
||||
[0]=>
|
||||
int(2)
|
||||
[1]=>
|
||||
int(10)
|
||||
[2]=>
|
||||
int(45)
|
||||
}
|
||||
-- Iteration 3 --
|
||||
bool(true)
|
||||
array(3) {
|
||||
[0]=>
|
||||
int(2)
|
||||
[1]=>
|
||||
int(10)
|
||||
[2]=>
|
||||
int(45)
|
||||
}
|
||||
-- Iteration 4 --
|
||||
bool(true)
|
||||
array(3) {
|
||||
[0]=>
|
||||
int(2)
|
||||
[1]=>
|
||||
int(10)
|
||||
[2]=>
|
||||
int(45)
|
||||
}
|
||||
-- Iteration 5 --
|
||||
bool(true)
|
||||
array(3) {
|
||||
[0]=>
|
||||
int(2)
|
||||
[1]=>
|
||||
int(10)
|
||||
[2]=>
|
||||
int(45)
|
||||
}
|
||||
-- Iteration 6 --
|
||||
bool(true)
|
||||
array(3) {
|
||||
[0]=>
|
||||
int(2)
|
||||
[1]=>
|
||||
int(10)
|
||||
[2]=>
|
||||
int(45)
|
||||
}
|
||||
-- Iteration 7 --
|
||||
bool(true)
|
||||
array(3) {
|
||||
[0]=>
|
||||
int(2)
|
||||
[1]=>
|
||||
int(10)
|
||||
[2]=>
|
||||
int(45)
|
||||
}
|
||||
-- Iteration 8 --
|
||||
bool(true)
|
||||
array(3) {
|
||||
[0]=>
|
||||
int(2)
|
||||
[1]=>
|
||||
int(10)
|
||||
[2]=>
|
||||
int(45)
|
||||
}
|
||||
-- Iteration 9 --
|
||||
bool(true)
|
||||
array(3) {
|
||||
[0]=>
|
||||
int(2)
|
||||
[1]=>
|
||||
int(10)
|
||||
[2]=>
|
||||
int(45)
|
||||
}
|
||||
-- Iteration 10 --
|
||||
bool(true)
|
||||
array(3) {
|
||||
[0]=>
|
||||
int(2)
|
||||
[1]=>
|
||||
int(10)
|
||||
[2]=>
|
||||
int(45)
|
||||
}
|
||||
-- Iteration 11 --
|
||||
bool(true)
|
||||
array(3) {
|
||||
[0]=>
|
||||
int(2)
|
||||
[1]=>
|
||||
int(10)
|
||||
[2]=>
|
||||
int(45)
|
||||
}
|
||||
-- Iteration 12 --
|
||||
bool(true)
|
||||
array(3) {
|
||||
[0]=>
|
||||
int(2)
|
||||
[1]=>
|
||||
int(10)
|
||||
[2]=>
|
||||
int(45)
|
||||
}
|
||||
-- Iteration 13 --
|
||||
|
||||
Warning: sort() expects parameter 2 to be long, string given in %s on line %d
|
||||
bool(false)
|
||||
array(3) {
|
||||
[0]=>
|
||||
int(10)
|
||||
[1]=>
|
||||
int(2)
|
||||
[2]=>
|
||||
int(45)
|
||||
}
|
||||
-- Iteration 14 --
|
||||
|
||||
Warning: sort() expects parameter 2 to be long, string given in %s on line %d
|
||||
bool(false)
|
||||
array(3) {
|
||||
[0]=>
|
||||
int(10)
|
||||
[1]=>
|
||||
int(2)
|
||||
[2]=>
|
||||
int(45)
|
||||
}
|
||||
-- Iteration 15 --
|
||||
|
||||
Warning: sort() expects parameter 2 to be long, string given in %s on line %d
|
||||
bool(false)
|
||||
array(3) {
|
||||
[0]=>
|
||||
int(10)
|
||||
[1]=>
|
||||
int(2)
|
||||
[2]=>
|
||||
int(45)
|
||||
}
|
||||
-- Iteration 16 --
|
||||
|
||||
Warning: sort() expects parameter 2 to be long, string given in %s on line %d
|
||||
bool(false)
|
||||
array(3) {
|
||||
[0]=>
|
||||
int(10)
|
||||
[1]=>
|
||||
int(2)
|
||||
[2]=>
|
||||
int(45)
|
||||
}
|
||||
-- Iteration 17 --
|
||||
|
||||
Warning: sort() expects parameter 2 to be long, object given in %s on line %d
|
||||
bool(false)
|
||||
array(3) {
|
||||
[0]=>
|
||||
int(10)
|
||||
[1]=>
|
||||
int(2)
|
||||
[2]=>
|
||||
int(45)
|
||||
}
|
||||
-- Iteration 18 --
|
||||
|
||||
Warning: sort() expects parameter 2 to be long, string given in %s on line %d
|
||||
bool(false)
|
||||
array(3) {
|
||||
[0]=>
|
||||
int(10)
|
||||
[1]=>
|
||||
int(2)
|
||||
[2]=>
|
||||
int(45)
|
||||
}
|
||||
-- Iteration 19 --
|
||||
|
||||
Warning: sort() expects parameter 2 to be long, string given in %s on line %d
|
||||
bool(false)
|
||||
array(3) {
|
||||
[0]=>
|
||||
int(10)
|
||||
[1]=>
|
||||
int(2)
|
||||
[2]=>
|
||||
int(45)
|
||||
}
|
||||
-- Iteration 20 --
|
||||
|
||||
Warning: sort() expects parameter 2 to be long, resource given in %s on line %d
|
||||
bool(false)
|
||||
array(3) {
|
||||
[0]=>
|
||||
int(10)
|
||||
[1]=>
|
||||
int(2)
|
||||
[2]=>
|
||||
int(45)
|
||||
}
|
||||
Done
|
328
ext/standard/tests/array/sort_variation3.phpt
Normal file
328
ext/standard/tests/array/sort_variation3.phpt
Normal file
@ -0,0 +1,328 @@
|
||||
--TEST--
|
||||
Test sort() function : usage variations - sort integer/float values
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : bool sort ( array &$array [, int $sort_flags] )
|
||||
* Description: This function sorts an array.
|
||||
Elements will be arranged from lowest to highest when this function has completed.
|
||||
* Source code: ext/standard/array.c
|
||||
*/
|
||||
|
||||
/*
|
||||
* Testing sort() by providing different integer/float value arrays for $array argument
|
||||
* with following flag values
|
||||
* 1. flag value as defualt
|
||||
* 2. SORT_REGULAR - compare items normally
|
||||
* 3. SORT_NUMERIC - compare items numerically
|
||||
* 4. SORT_STRING - compare items as strings
|
||||
*/
|
||||
|
||||
echo "*** Testing sort() : usage variations ***\n";
|
||||
|
||||
// group of various arrays
|
||||
$various_arrays = array (
|
||||
// negative/posative integers array
|
||||
array(11, -11, 21, -21, 31, -31, 0, 41, -41),
|
||||
|
||||
// float value array
|
||||
array(10.5, -10.5, 10.5e2, 10.6E-2, .5, .01, -.1),
|
||||
|
||||
// mixed value array
|
||||
array(.0001, .0021, -.01, -1, 0, .09, 2, -.9, 10.6E-2, -10.6E-2, 33),
|
||||
|
||||
// array values contains minimum and maximum ranges
|
||||
array(2147483647, 2147483648, -2147483647, -2147483648, -0, 0, -2147483649)
|
||||
);
|
||||
|
||||
// set of possible flag values
|
||||
$flag_value = array("SORT_REGULAR" => SORT_REGULAR, "SORT_NUMERIC" => SORT_NUMERIC);
|
||||
|
||||
$count = 1;
|
||||
echo "\n-- Testing sort() by supplying various integer/float arrays --\n";
|
||||
|
||||
// loop through to test sort() with different arrays
|
||||
foreach ($various_arrays as $array) {
|
||||
echo "\n-- Iteration $count --\n";
|
||||
|
||||
echo "- With Defualt sort flag -\n";
|
||||
$temp_array = $array;
|
||||
var_dump(sort($temp_array) );
|
||||
var_dump($temp_array);
|
||||
|
||||
// loop through $flag_value array and setting all possible flag values
|
||||
foreach($flag_value as $key => $flag){
|
||||
echo "- Sort flag = $key -\n";
|
||||
$temp_array = $array;
|
||||
var_dump(sort($temp_array, $flag) );
|
||||
var_dump($temp_array);
|
||||
}
|
||||
$count++;
|
||||
}
|
||||
|
||||
echo "Done\n";
|
||||
?>
|
||||
--EXPECTF--
|
||||
*** Testing sort() : usage variations ***
|
||||
|
||||
-- Testing sort() by supplying various integer/float arrays --
|
||||
|
||||
-- Iteration 1 --
|
||||
- With Defualt sort flag -
|
||||
bool(true)
|
||||
array(9) {
|
||||
[0]=>
|
||||
int(-41)
|
||||
[1]=>
|
||||
int(-31)
|
||||
[2]=>
|
||||
int(-21)
|
||||
[3]=>
|
||||
int(-11)
|
||||
[4]=>
|
||||
int(0)
|
||||
[5]=>
|
||||
int(11)
|
||||
[6]=>
|
||||
int(21)
|
||||
[7]=>
|
||||
int(31)
|
||||
[8]=>
|
||||
int(41)
|
||||
}
|
||||
- Sort flag = SORT_REGULAR -
|
||||
bool(true)
|
||||
array(9) {
|
||||
[0]=>
|
||||
int(-41)
|
||||
[1]=>
|
||||
int(-31)
|
||||
[2]=>
|
||||
int(-21)
|
||||
[3]=>
|
||||
int(-11)
|
||||
[4]=>
|
||||
int(0)
|
||||
[5]=>
|
||||
int(11)
|
||||
[6]=>
|
||||
int(21)
|
||||
[7]=>
|
||||
int(31)
|
||||
[8]=>
|
||||
int(41)
|
||||
}
|
||||
- Sort flag = SORT_NUMERIC -
|
||||
bool(true)
|
||||
array(9) {
|
||||
[0]=>
|
||||
int(-41)
|
||||
[1]=>
|
||||
int(-31)
|
||||
[2]=>
|
||||
int(-21)
|
||||
[3]=>
|
||||
int(-11)
|
||||
[4]=>
|
||||
int(0)
|
||||
[5]=>
|
||||
int(11)
|
||||
[6]=>
|
||||
int(21)
|
||||
[7]=>
|
||||
int(31)
|
||||
[8]=>
|
||||
int(41)
|
||||
}
|
||||
|
||||
-- Iteration 2 --
|
||||
- With Defualt sort flag -
|
||||
bool(true)
|
||||
array(7) {
|
||||
[0]=>
|
||||
float(-10.5)
|
||||
[1]=>
|
||||
float(-0.1)
|
||||
[2]=>
|
||||
float(0.01)
|
||||
[3]=>
|
||||
float(0.106)
|
||||
[4]=>
|
||||
float(0.5)
|
||||
[5]=>
|
||||
float(10.5)
|
||||
[6]=>
|
||||
float(1050)
|
||||
}
|
||||
- Sort flag = SORT_REGULAR -
|
||||
bool(true)
|
||||
array(7) {
|
||||
[0]=>
|
||||
float(-10.5)
|
||||
[1]=>
|
||||
float(-0.1)
|
||||
[2]=>
|
||||
float(0.01)
|
||||
[3]=>
|
||||
float(0.106)
|
||||
[4]=>
|
||||
float(0.5)
|
||||
[5]=>
|
||||
float(10.5)
|
||||
[6]=>
|
||||
float(1050)
|
||||
}
|
||||
- Sort flag = SORT_NUMERIC -
|
||||
bool(true)
|
||||
array(7) {
|
||||
[0]=>
|
||||
float(-10.5)
|
||||
[1]=>
|
||||
float(-0.1)
|
||||
[2]=>
|
||||
float(0.01)
|
||||
[3]=>
|
||||
float(0.106)
|
||||
[4]=>
|
||||
float(0.5)
|
||||
[5]=>
|
||||
float(10.5)
|
||||
[6]=>
|
||||
float(1050)
|
||||
}
|
||||
|
||||
-- Iteration 3 --
|
||||
- With Defualt sort flag -
|
||||
bool(true)
|
||||
array(11) {
|
||||
[0]=>
|
||||
int(-1)
|
||||
[1]=>
|
||||
float(-0.9)
|
||||
[2]=>
|
||||
float(-0.106)
|
||||
[3]=>
|
||||
float(-0.01)
|
||||
[4]=>
|
||||
int(0)
|
||||
[5]=>
|
||||
float(0.0001)
|
||||
[6]=>
|
||||
float(0.0021)
|
||||
[7]=>
|
||||
float(0.09)
|
||||
[8]=>
|
||||
float(0.106)
|
||||
[9]=>
|
||||
int(2)
|
||||
[10]=>
|
||||
int(33)
|
||||
}
|
||||
- Sort flag = SORT_REGULAR -
|
||||
bool(true)
|
||||
array(11) {
|
||||
[0]=>
|
||||
int(-1)
|
||||
[1]=>
|
||||
float(-0.9)
|
||||
[2]=>
|
||||
float(-0.106)
|
||||
[3]=>
|
||||
float(-0.01)
|
||||
[4]=>
|
||||
int(0)
|
||||
[5]=>
|
||||
float(0.0001)
|
||||
[6]=>
|
||||
float(0.0021)
|
||||
[7]=>
|
||||
float(0.09)
|
||||
[8]=>
|
||||
float(0.106)
|
||||
[9]=>
|
||||
int(2)
|
||||
[10]=>
|
||||
int(33)
|
||||
}
|
||||
- Sort flag = SORT_NUMERIC -
|
||||
bool(true)
|
||||
array(11) {
|
||||
[0]=>
|
||||
int(-1)
|
||||
[1]=>
|
||||
float(-0.9)
|
||||
[2]=>
|
||||
float(-0.106)
|
||||
[3]=>
|
||||
float(-0.01)
|
||||
[4]=>
|
||||
int(0)
|
||||
[5]=>
|
||||
float(0.0001)
|
||||
[6]=>
|
||||
float(0.0021)
|
||||
[7]=>
|
||||
float(0.09)
|
||||
[8]=>
|
||||
float(0.106)
|
||||
[9]=>
|
||||
int(2)
|
||||
[10]=>
|
||||
int(33)
|
||||
}
|
||||
|
||||
-- Iteration 4 --
|
||||
- With Defualt sort flag -
|
||||
bool(true)
|
||||
array(7) {
|
||||
[0]=>
|
||||
float(-2147483649)
|
||||
[1]=>
|
||||
float(-2147483648)
|
||||
[2]=>
|
||||
int(-2147483647)
|
||||
[3]=>
|
||||
int(0)
|
||||
[4]=>
|
||||
int(0)
|
||||
[5]=>
|
||||
int(2147483647)
|
||||
[6]=>
|
||||
float(2147483648)
|
||||
}
|
||||
- Sort flag = SORT_REGULAR -
|
||||
bool(true)
|
||||
array(7) {
|
||||
[0]=>
|
||||
float(-2147483649)
|
||||
[1]=>
|
||||
float(-2147483648)
|
||||
[2]=>
|
||||
int(-2147483647)
|
||||
[3]=>
|
||||
int(0)
|
||||
[4]=>
|
||||
int(0)
|
||||
[5]=>
|
||||
int(2147483647)
|
||||
[6]=>
|
||||
float(2147483648)
|
||||
}
|
||||
- Sort flag = SORT_NUMERIC -
|
||||
bool(true)
|
||||
array(7) {
|
||||
[0]=>
|
||||
float(-2147483649)
|
||||
[1]=>
|
||||
float(-2147483648)
|
||||
[2]=>
|
||||
int(-2147483647)
|
||||
[3]=>
|
||||
int(0)
|
||||
[4]=>
|
||||
int(0)
|
||||
[5]=>
|
||||
int(2147483647)
|
||||
[6]=>
|
||||
float(2147483648)
|
||||
}
|
||||
Done
|
79
ext/standard/tests/array/sort_variation4.phpt
Normal file
79
ext/standard/tests/array/sort_variation4.phpt
Normal file
@ -0,0 +1,79 @@
|
||||
--TEST--
|
||||
Test sort() function : usage variations - sort reference values
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : bool sort ( array &$array [, int $sort_flags] )
|
||||
* Description: This function sorts an array.
|
||||
Elements will be arranged from lowest to highest when this function has completed.
|
||||
* Source code: ext/standard/array.c
|
||||
*/
|
||||
|
||||
/*
|
||||
* Testing sort() by providing reference variable array with following flag values
|
||||
* flag value as defualt
|
||||
* SORT_REGULAR - compare items normally
|
||||
* SORT_NUMERIC - compare items numerically
|
||||
*/
|
||||
|
||||
echo "*** Testing sort() :usage variations ***\n";
|
||||
|
||||
$value1 = 100;
|
||||
$value2 = 33;
|
||||
$value3 = 555;
|
||||
|
||||
// an array containing integer references
|
||||
$unsorted_numerics = array( &$value1 , &$value2, &$value3);
|
||||
|
||||
echo "\n-- Testing sort() by supplying reference variable array, 'flag' value is defualt --\n";
|
||||
$temp_array = $unsorted_numerics;
|
||||
var_dump( sort($temp_array) ); // expecting : bool(true)
|
||||
var_dump( $temp_array);
|
||||
|
||||
echo "\n-- Testing sort() by supplying reference variable array, 'flag' = SORT_REGULAR --\n";
|
||||
$temp_array = &$unsorted_numerics;
|
||||
var_dump( sort($temp_array, SORT_REGULAR) ); // expecting : bool(true)
|
||||
var_dump( $temp_array);
|
||||
|
||||
echo "\n-- Testing sort() by supplying reference variable array, 'flag' = SORT_NUMERIC --\n";
|
||||
$temp_array = &$unsorted_numerics;
|
||||
var_dump( sort($temp_array, SORT_NUMERIC) ); // expecting : bool(true)
|
||||
var_dump( $temp_array);
|
||||
|
||||
echo "Done\n";
|
||||
?>
|
||||
--EXPECTF--
|
||||
*** Testing sort() :usage variations ***
|
||||
|
||||
-- Testing sort() by supplying reference variable array, 'flag' value is defualt --
|
||||
bool(true)
|
||||
array(3) {
|
||||
[0]=>
|
||||
&int(33)
|
||||
[1]=>
|
||||
&int(100)
|
||||
[2]=>
|
||||
&int(555)
|
||||
}
|
||||
|
||||
-- Testing sort() by supplying reference variable array, 'flag' = SORT_REGULAR --
|
||||
bool(true)
|
||||
array(3) {
|
||||
[0]=>
|
||||
&int(33)
|
||||
[1]=>
|
||||
&int(100)
|
||||
[2]=>
|
||||
&int(555)
|
||||
}
|
||||
|
||||
-- Testing sort() by supplying reference variable array, 'flag' = SORT_NUMERIC --
|
||||
bool(true)
|
||||
array(3) {
|
||||
[0]=>
|
||||
&int(33)
|
||||
[1]=>
|
||||
&int(100)
|
||||
[2]=>
|
||||
&int(555)
|
||||
}
|
||||
Done
|
236
ext/standard/tests/array/sort_variation5.phpt
Normal file
236
ext/standard/tests/array/sort_variation5.phpt
Normal file
@ -0,0 +1,236 @@
|
||||
--TEST--
|
||||
Test sort() function : usage variations - sort strings
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : bool sort ( array &$array [, int $sort_flags] )
|
||||
* Description: This function sorts an array.
|
||||
Elements will be arranged from lowest to highest when this function has completed.
|
||||
* Source code: ext/standard/array.c
|
||||
*/
|
||||
|
||||
/*
|
||||
* testing sort() by providing different string arrays for $array argument with following flag values
|
||||
* flag value as defualt
|
||||
* SORT_REGULAR - compare items normally
|
||||
* SORT_STRING - compare items as strings
|
||||
*/
|
||||
|
||||
echo "*** Testing sort() : usage variations ***\n";
|
||||
|
||||
$various_arrays = array (
|
||||
// group of escape sequences
|
||||
array(null, NULL, "\a", "\cx", "\e", "\f", "\n", "\r", "\t", "\xhh", "\ddd", "\v"),
|
||||
|
||||
// array contains combination of capital/small letters
|
||||
array("lemoN", "Orange", "banana", "apple", "Test", "TTTT", "ttt", "ww", "x", "X", "oraNGe", "BANANA")
|
||||
);
|
||||
|
||||
$flags = array("SORT_REGULAR" => SORT_REGULAR, "SORT_STRING" => SORT_STRING);
|
||||
|
||||
$count = 1;
|
||||
echo "\n-- Testing sort() by supplying various string arrays --\n";
|
||||
|
||||
// loop through to test sort() with different arrays
|
||||
foreach ($various_arrays as $array) {
|
||||
echo "\n-- Iteration $count --\n";
|
||||
|
||||
echo "- With Default sort flag -\n";
|
||||
$temp_array = $array;
|
||||
var_dump(sort($temp_array) ); // expecting : bool(true)
|
||||
var_dump($temp_array);
|
||||
|
||||
// loop through $flags array and setting all possible flag values
|
||||
foreach($flags as $key => $flag){
|
||||
echo "- Sort flag = $key -\n";
|
||||
$temp_array = $array;
|
||||
var_dump(sort($temp_array, $flag) ); // expecting : bool(true)
|
||||
var_dump($temp_array);
|
||||
}
|
||||
$count++;
|
||||
}
|
||||
|
||||
echo "Done\n";
|
||||
?>
|
||||
--EXPECTF--
|
||||
*** Testing sort() : usage variations ***
|
||||
|
||||
-- Testing sort() by supplying various string arrays --
|
||||
|
||||
-- Iteration 1 --
|
||||
- With Default sort flag -
|
||||
bool(true)
|
||||
array(12) {
|
||||
[0]=>
|
||||
NULL
|
||||
[1]=>
|
||||
NULL
|
||||
[2]=>
|
||||
string(1) " "
|
||||
[3]=>
|
||||
string(1) "
|
||||
"
|
||||
[4]=>
|
||||
string(1) ""
|
||||
[5]=>
|
||||
string(1) ""
|
||||
[6]=>
|
||||
string(1) "
|
||||
"
|
||||
[7]=>
|
||||
string(2) "\a"
|
||||
[8]=>
|
||||
string(3) "\cx"
|
||||
[9]=>
|
||||
string(4) "\ddd"
|
||||
[10]=>
|
||||
string(2) "\e"
|
||||
[11]=>
|
||||
string(4) "\xhh"
|
||||
}
|
||||
- Sort flag = SORT_REGULAR -
|
||||
bool(true)
|
||||
array(12) {
|
||||
[0]=>
|
||||
NULL
|
||||
[1]=>
|
||||
NULL
|
||||
[2]=>
|
||||
string(1) " "
|
||||
[3]=>
|
||||
string(1) "
|
||||
"
|
||||
[4]=>
|
||||
string(1) ""
|
||||
[5]=>
|
||||
string(1) ""
|
||||
[6]=>
|
||||
string(1) "
|
||||
"
|
||||
[7]=>
|
||||
string(2) "\a"
|
||||
[8]=>
|
||||
string(3) "\cx"
|
||||
[9]=>
|
||||
string(4) "\ddd"
|
||||
[10]=>
|
||||
string(2) "\e"
|
||||
[11]=>
|
||||
string(4) "\xhh"
|
||||
}
|
||||
- Sort flag = SORT_STRING -
|
||||
bool(true)
|
||||
array(12) {
|
||||
[0]=>
|
||||
NULL
|
||||
[1]=>
|
||||
NULL
|
||||
[2]=>
|
||||
string(1) " "
|
||||
[3]=>
|
||||
string(1) "
|
||||
"
|
||||
[4]=>
|
||||
string(1) ""
|
||||
[5]=>
|
||||
string(1) ""
|
||||
[6]=>
|
||||
string(1) "
|
||||
"
|
||||
[7]=>
|
||||
string(2) "\a"
|
||||
[8]=>
|
||||
string(3) "\cx"
|
||||
[9]=>
|
||||
string(4) "\ddd"
|
||||
[10]=>
|
||||
string(2) "\e"
|
||||
[11]=>
|
||||
string(4) "\xhh"
|
||||
}
|
||||
|
||||
-- Iteration 2 --
|
||||
- With Default sort flag -
|
||||
bool(true)
|
||||
array(12) {
|
||||
[0]=>
|
||||
string(6) "BANANA"
|
||||
[1]=>
|
||||
string(6) "Orange"
|
||||
[2]=>
|
||||
string(4) "TTTT"
|
||||
[3]=>
|
||||
string(4) "Test"
|
||||
[4]=>
|
||||
string(1) "X"
|
||||
[5]=>
|
||||
string(5) "apple"
|
||||
[6]=>
|
||||
string(6) "banana"
|
||||
[7]=>
|
||||
string(5) "lemoN"
|
||||
[8]=>
|
||||
string(6) "oraNGe"
|
||||
[9]=>
|
||||
string(3) "ttt"
|
||||
[10]=>
|
||||
string(2) "ww"
|
||||
[11]=>
|
||||
string(1) "x"
|
||||
}
|
||||
- Sort flag = SORT_REGULAR -
|
||||
bool(true)
|
||||
array(12) {
|
||||
[0]=>
|
||||
string(6) "BANANA"
|
||||
[1]=>
|
||||
string(6) "Orange"
|
||||
[2]=>
|
||||
string(4) "TTTT"
|
||||
[3]=>
|
||||
string(4) "Test"
|
||||
[4]=>
|
||||
string(1) "X"
|
||||
[5]=>
|
||||
string(5) "apple"
|
||||
[6]=>
|
||||
string(6) "banana"
|
||||
[7]=>
|
||||
string(5) "lemoN"
|
||||
[8]=>
|
||||
string(6) "oraNGe"
|
||||
[9]=>
|
||||
string(3) "ttt"
|
||||
[10]=>
|
||||
string(2) "ww"
|
||||
[11]=>
|
||||
string(1) "x"
|
||||
}
|
||||
- Sort flag = SORT_STRING -
|
||||
bool(true)
|
||||
array(12) {
|
||||
[0]=>
|
||||
string(6) "BANANA"
|
||||
[1]=>
|
||||
string(6) "Orange"
|
||||
[2]=>
|
||||
string(4) "TTTT"
|
||||
[3]=>
|
||||
string(4) "Test"
|
||||
[4]=>
|
||||
string(1) "X"
|
||||
[5]=>
|
||||
string(5) "apple"
|
||||
[6]=>
|
||||
string(6) "banana"
|
||||
[7]=>
|
||||
string(5) "lemoN"
|
||||
[8]=>
|
||||
string(6) "oraNGe"
|
||||
[9]=>
|
||||
string(3) "ttt"
|
||||
[10]=>
|
||||
string(2) "ww"
|
||||
[11]=>
|
||||
string(1) "x"
|
||||
}
|
||||
Done
|
123
ext/standard/tests/array/sort_variation6.phpt
Normal file
123
ext/standard/tests/array/sort_variation6.phpt
Normal file
@ -0,0 +1,123 @@
|
||||
--TEST--
|
||||
Test sort() function : usage variations - sort hexadecimal values
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : bool sort ( array &$array [, int $sort_flags] )
|
||||
* Description: This function sorts an array.
|
||||
Elements will be arranged from lowest to highest when this function has completed.
|
||||
* Source code: ext/standard/array.c
|
||||
*/
|
||||
|
||||
/*
|
||||
* testing sort() by providing different hexa-decimal array for $array argument with following flag values
|
||||
* flag value as defualt
|
||||
* SORT_REGULAR - compare items normally
|
||||
* SORT_NUMERIC - compare items numerically
|
||||
*/
|
||||
|
||||
echo "*** Testing sort() : usage variations ***\n";
|
||||
|
||||
// an array contains unsorted hexadecimal values
|
||||
$unsorted_hex_array = array(0x1AB, 0xFFF, 0xF, 0xFF, 0x2AA, 0xBB, 0x1ab, 0xff, -0xFF, 0, -0x2aa);
|
||||
|
||||
echo "\n-- Testing sort() by supplying hexadecimal value array, 'flag' value is defualt --\n";
|
||||
$temp_array = $unsorted_hex_array;
|
||||
var_dump(sort($temp_array) ); // expecting : bool(true)
|
||||
var_dump($temp_array);
|
||||
|
||||
echo "\n-- Testing sort() by supplying hexadecimal value array, 'flag' value is SORT_REGULAR --\n";
|
||||
$temp_array = $unsorted_hex_array;
|
||||
var_dump(sort($temp_array, SORT_REGULAR) ); // expecting : bool(true)
|
||||
var_dump($temp_array);
|
||||
|
||||
echo "\n-- Testing sort() by supplying hexadecimal value array, 'flag' value is SORT_NUMERIC --\n";
|
||||
$temp_array = $unsorted_hex_array;
|
||||
var_dump(sort($temp_array, SORT_NUMERIC) ); // expecting : bool(true)
|
||||
var_dump($temp_array);
|
||||
|
||||
echo "Done\n";
|
||||
?>
|
||||
--EXPECTF--
|
||||
*** Testing sort() : usage variations ***
|
||||
|
||||
-- Testing sort() by supplying hexadecimal value array, 'flag' value is defualt --
|
||||
bool(true)
|
||||
array(11) {
|
||||
[0]=>
|
||||
int(-682)
|
||||
[1]=>
|
||||
int(-255)
|
||||
[2]=>
|
||||
int(0)
|
||||
[3]=>
|
||||
int(15)
|
||||
[4]=>
|
||||
int(187)
|
||||
[5]=>
|
||||
int(255)
|
||||
[6]=>
|
||||
int(255)
|
||||
[7]=>
|
||||
int(427)
|
||||
[8]=>
|
||||
int(427)
|
||||
[9]=>
|
||||
int(682)
|
||||
[10]=>
|
||||
int(4095)
|
||||
}
|
||||
|
||||
-- Testing sort() by supplying hexadecimal value array, 'flag' value is SORT_REGULAR --
|
||||
bool(true)
|
||||
array(11) {
|
||||
[0]=>
|
||||
int(-682)
|
||||
[1]=>
|
||||
int(-255)
|
||||
[2]=>
|
||||
int(0)
|
||||
[3]=>
|
||||
int(15)
|
||||
[4]=>
|
||||
int(187)
|
||||
[5]=>
|
||||
int(255)
|
||||
[6]=>
|
||||
int(255)
|
||||
[7]=>
|
||||
int(427)
|
||||
[8]=>
|
||||
int(427)
|
||||
[9]=>
|
||||
int(682)
|
||||
[10]=>
|
||||
int(4095)
|
||||
}
|
||||
|
||||
-- Testing sort() by supplying hexadecimal value array, 'flag' value is SORT_NUMERIC --
|
||||
bool(true)
|
||||
array(11) {
|
||||
[0]=>
|
||||
int(-682)
|
||||
[1]=>
|
||||
int(-255)
|
||||
[2]=>
|
||||
int(0)
|
||||
[3]=>
|
||||
int(15)
|
||||
[4]=>
|
||||
int(187)
|
||||
[5]=>
|
||||
int(255)
|
||||
[6]=>
|
||||
int(255)
|
||||
[7]=>
|
||||
int(427)
|
||||
[8]=>
|
||||
int(427)
|
||||
[9]=>
|
||||
int(682)
|
||||
[10]=>
|
||||
int(4095)
|
||||
}
|
||||
Done
|
98
ext/standard/tests/array/sort_variation7.phpt
Normal file
98
ext/standard/tests/array/sort_variation7.phpt
Normal file
@ -0,0 +1,98 @@
|
||||
--TEST--
|
||||
Test sort() function : usage variations - sort boolean values
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : bool sort ( array &$array [, int $sort_flags] )
|
||||
* Description: This function sorts an array.
|
||||
Elements will be arranged from lowest to highest when this function has completed.
|
||||
* Source code: ext/standard/array.c
|
||||
*/
|
||||
|
||||
/*
|
||||
* testing sort() by providing bool value array for $array argument with following flag values.
|
||||
* flag value as defualt
|
||||
* SORT_REGULAR - compare items normally
|
||||
*/
|
||||
|
||||
echo "*** Testing sort() : usage variations ***\n";
|
||||
|
||||
// bool value array
|
||||
$bool_values = array (true, false, TRUE, FALSE);
|
||||
|
||||
echo "\n-- Testing sort() by supplying bool value array, 'flag' value is defualt --\n";
|
||||
$temp_array = $bool_values;
|
||||
var_dump(sort($temp_array) );
|
||||
var_dump($temp_array);
|
||||
|
||||
echo "\n-- Testing sort() by supplying bool value array, 'flag' value is SORT_REGULAR --\n";
|
||||
$temp_array = $bool_values;
|
||||
var_dump(sort($temp_array, SORT_REGULAR) );
|
||||
var_dump($temp_array);
|
||||
|
||||
echo "\n-- Testing sort() by supplying bool value array, 'flag' value is SORT_NUMERIC --\n";
|
||||
$temp_array = $bool_values;
|
||||
var_dump(sort($temp_array, SORT_NUMERIC) );
|
||||
var_dump($temp_array);
|
||||
|
||||
echo "\n-- Testing sort() by supplying bool value array, 'flag' value is SORT_STRING --\n";
|
||||
$temp_array = $bool_values;
|
||||
var_dump(sort($temp_array, SORT_STRING) );
|
||||
var_dump($temp_array);
|
||||
|
||||
echo "Done\n";
|
||||
?>
|
||||
--EXPECTF--
|
||||
*** Testing sort() : usage variations ***
|
||||
|
||||
-- Testing sort() by supplying bool value array, 'flag' value is defualt --
|
||||
bool(true)
|
||||
array(4) {
|
||||
[0]=>
|
||||
bool(false)
|
||||
[1]=>
|
||||
bool(false)
|
||||
[2]=>
|
||||
bool(true)
|
||||
[3]=>
|
||||
bool(true)
|
||||
}
|
||||
|
||||
-- Testing sort() by supplying bool value array, 'flag' value is SORT_REGULAR --
|
||||
bool(true)
|
||||
array(4) {
|
||||
[0]=>
|
||||
bool(false)
|
||||
[1]=>
|
||||
bool(false)
|
||||
[2]=>
|
||||
bool(true)
|
||||
[3]=>
|
||||
bool(true)
|
||||
}
|
||||
|
||||
-- Testing sort() by supplying bool value array, 'flag' value is SORT_NUMERIC --
|
||||
bool(true)
|
||||
array(4) {
|
||||
[0]=>
|
||||
bool(false)
|
||||
[1]=>
|
||||
bool(false)
|
||||
[2]=>
|
||||
bool(true)
|
||||
[3]=>
|
||||
bool(true)
|
||||
}
|
||||
|
||||
-- Testing sort() by supplying bool value array, 'flag' value is SORT_STRING --
|
||||
bool(true)
|
||||
array(4) {
|
||||
[0]=>
|
||||
bool(false)
|
||||
[1]=>
|
||||
bool(false)
|
||||
[2]=>
|
||||
bool(true)
|
||||
[3]=>
|
||||
bool(true)
|
||||
}
|
||||
Done
|
178
ext/standard/tests/array/sort_variation8.phpt
Normal file
178
ext/standard/tests/array/sort_variation8.phpt
Normal file
@ -0,0 +1,178 @@
|
||||
--TEST--
|
||||
Test sort() function : usage variations - sort array with diff. sub arrays, 'sort_flags' as defualt/SORT_REGULAR
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : bool sort ( array &$array [, int $sort_flags] )
|
||||
* Description: This function sorts an array.
|
||||
Elements will be arranged from lowest to highest when this function has completed.
|
||||
* Source code: ext/standard/array.c
|
||||
*/
|
||||
|
||||
/*
|
||||
* testing sort() by providing arrays contains sub arrays for $array argument with flowing flag values
|
||||
* flag value as defualt
|
||||
* SORT_REGULAR - compare items normally
|
||||
*/
|
||||
|
||||
echo "*** Testing sort() : usage variations ***\n";
|
||||
|
||||
// array of arrays
|
||||
$various_arrays = array (
|
||||
// null array
|
||||
array(),
|
||||
|
||||
// array contains null sub array
|
||||
array( array() ),
|
||||
|
||||
// array of arrays along with some values
|
||||
array(44, 11, array(64, 61) ),
|
||||
|
||||
// array containing sub arrays
|
||||
array(array(33, -5, 6), array(11), array(22, -55), array() )
|
||||
);
|
||||
|
||||
|
||||
$count = 1;
|
||||
echo "\n-- Testing sort() by supplying various arrays containing sub arrays --\n";
|
||||
|
||||
// loop through to test sort() with different arrays
|
||||
foreach ($various_arrays as $array) {
|
||||
|
||||
echo "\n-- Iteration $count --\n";
|
||||
// testing sort() function by supplying different arrays, flag value is defualt
|
||||
echo "- With Defualt sort flag -\n";
|
||||
$temp_array = $array;
|
||||
var_dump(sort($temp_array) );
|
||||
var_dump($temp_array);
|
||||
|
||||
// testing sort() function by supplying different arrays, flag value = SORT_REGULAR
|
||||
echo "- Sort flag = SORT_REGULAR -\n";
|
||||
$temp_array = $array;
|
||||
var_dump(sort($temp_array, SORT_REGULAR) );
|
||||
var_dump($temp_array);
|
||||
$count++;
|
||||
}
|
||||
|
||||
echo "Done\n";
|
||||
?>
|
||||
--EXPECTF--
|
||||
*** Testing sort() : usage variations ***
|
||||
|
||||
-- Testing sort() by supplying various arrays containing sub arrays --
|
||||
|
||||
-- Iteration 1 --
|
||||
- With Defualt sort flag -
|
||||
bool(true)
|
||||
array(0) {
|
||||
}
|
||||
- Sort flag = SORT_REGULAR -
|
||||
bool(true)
|
||||
array(0) {
|
||||
}
|
||||
|
||||
-- Iteration 2 --
|
||||
- With Defualt sort flag -
|
||||
bool(true)
|
||||
array(1) {
|
||||
[0]=>
|
||||
array(0) {
|
||||
}
|
||||
}
|
||||
- Sort flag = SORT_REGULAR -
|
||||
bool(true)
|
||||
array(1) {
|
||||
[0]=>
|
||||
array(0) {
|
||||
}
|
||||
}
|
||||
|
||||
-- Iteration 3 --
|
||||
- With Defualt sort flag -
|
||||
bool(true)
|
||||
array(3) {
|
||||
[0]=>
|
||||
int(11)
|
||||
[1]=>
|
||||
int(44)
|
||||
[2]=>
|
||||
array(2) {
|
||||
[0]=>
|
||||
int(64)
|
||||
[1]=>
|
||||
int(61)
|
||||
}
|
||||
}
|
||||
- Sort flag = SORT_REGULAR -
|
||||
bool(true)
|
||||
array(3) {
|
||||
[0]=>
|
||||
int(11)
|
||||
[1]=>
|
||||
int(44)
|
||||
[2]=>
|
||||
array(2) {
|
||||
[0]=>
|
||||
int(64)
|
||||
[1]=>
|
||||
int(61)
|
||||
}
|
||||
}
|
||||
|
||||
-- Iteration 4 --
|
||||
- With Defualt sort flag -
|
||||
bool(true)
|
||||
array(4) {
|
||||
[0]=>
|
||||
array(0) {
|
||||
}
|
||||
[1]=>
|
||||
array(1) {
|
||||
[0]=>
|
||||
int(11)
|
||||
}
|
||||
[2]=>
|
||||
array(2) {
|
||||
[0]=>
|
||||
int(22)
|
||||
[1]=>
|
||||
int(-55)
|
||||
}
|
||||
[3]=>
|
||||
array(3) {
|
||||
[0]=>
|
||||
int(33)
|
||||
[1]=>
|
||||
int(-5)
|
||||
[2]=>
|
||||
int(6)
|
||||
}
|
||||
}
|
||||
- Sort flag = SORT_REGULAR -
|
||||
bool(true)
|
||||
array(4) {
|
||||
[0]=>
|
||||
array(0) {
|
||||
}
|
||||
[1]=>
|
||||
array(1) {
|
||||
[0]=>
|
||||
int(11)
|
||||
}
|
||||
[2]=>
|
||||
array(2) {
|
||||
[0]=>
|
||||
int(22)
|
||||
[1]=>
|
||||
int(-55)
|
||||
}
|
||||
[3]=>
|
||||
array(3) {
|
||||
[0]=>
|
||||
int(33)
|
||||
[1]=>
|
||||
int(-5)
|
||||
[2]=>
|
||||
int(6)
|
||||
}
|
||||
}
|
||||
Done
|
259
ext/standard/tests/array/sort_variation9.phpt
Normal file
259
ext/standard/tests/array/sort_variation9.phpt
Normal file
@ -0,0 +1,259 @@
|
||||
--TEST--
|
||||
Test sort() function : usage variations - sort diff. associative arrays, 'sort_flags' as defualt/SORT_REGULAR
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : bool sort ( array &$array [, int $sort_flags] )
|
||||
* Description: This function sorts an array.
|
||||
Elements will be arranged from lowest to highest when this function has completed.
|
||||
* Source code: ext/standard/array.c
|
||||
*/
|
||||
|
||||
/*
|
||||
* Testing sort() by providing arrays with key values for $array argument
|
||||
* with following flag values.
|
||||
* 1.flag value as defualt
|
||||
* 2.SORT_REGULAR - compare items normally
|
||||
* To test the new keys for the elements in the sorted array.
|
||||
*/
|
||||
|
||||
echo "*** Testing sort() : usage variations ***\n";
|
||||
|
||||
// list of arrays with key and values
|
||||
$various_arrays = array(
|
||||
array(5 => 55, 6 => 66, 2 => 22, 3 => 33, 1 => 11),
|
||||
array ("fruits" => array("a" => "orange", "b" => "banana", "c" => "apple"),
|
||||
"numbers" => array(1, 2, 3, 4, 5, 6),
|
||||
"holes" => array("first", 5 => "second", "third")
|
||||
),
|
||||
array(1, 1, 8 => 1, 4 => 1, 19, 3 => 13),
|
||||
array('bar' => 'baz', "foo" => 1),
|
||||
array('a' => 1,'b' => array('e' => 2,'f' => 3),'c' => array('g' => 4),'d' => 5),
|
||||
);
|
||||
|
||||
$count = 1;
|
||||
echo "\n-- Testing sort() by supplying various arrays with key values --\n";
|
||||
|
||||
// loop through to test sort() with different arrays,
|
||||
// to test the new keys for the elements in the sorted array
|
||||
foreach ($various_arrays as $array) {
|
||||
echo "\n-- Iteration $count --\n";
|
||||
|
||||
echo "- With Defualt sort flag -\n";
|
||||
$temp_array = $array;
|
||||
var_dump(sort($temp_array) );
|
||||
var_dump($temp_array);
|
||||
|
||||
echo "- Sort flag = SORT_REGULAR -\n";
|
||||
$temp_array = $array;
|
||||
var_dump(sort($temp_array, SORT_REGULAR) );
|
||||
var_dump($temp_array);
|
||||
$count++;
|
||||
}
|
||||
|
||||
echo "Done\n";
|
||||
?>
|
||||
--EXPECTF--
|
||||
*** Testing sort() : usage variations ***
|
||||
|
||||
-- Testing sort() by supplying various arrays with key values --
|
||||
|
||||
-- Iteration 1 --
|
||||
- With Defualt sort flag -
|
||||
bool(true)
|
||||
array(5) {
|
||||
[0]=>
|
||||
int(11)
|
||||
[1]=>
|
||||
int(22)
|
||||
[2]=>
|
||||
int(33)
|
||||
[3]=>
|
||||
int(55)
|
||||
[4]=>
|
||||
int(66)
|
||||
}
|
||||
- Sort flag = SORT_REGULAR -
|
||||
bool(true)
|
||||
array(5) {
|
||||
[0]=>
|
||||
int(11)
|
||||
[1]=>
|
||||
int(22)
|
||||
[2]=>
|
||||
int(33)
|
||||
[3]=>
|
||||
int(55)
|
||||
[4]=>
|
||||
int(66)
|
||||
}
|
||||
|
||||
-- Iteration 2 --
|
||||
- With Defualt sort flag -
|
||||
bool(true)
|
||||
array(3) {
|
||||
[0]=>
|
||||
array(3) {
|
||||
[0]=>
|
||||
string(5) "first"
|
||||
[5]=>
|
||||
string(6) "second"
|
||||
[6]=>
|
||||
string(5) "third"
|
||||
}
|
||||
[1]=>
|
||||
array(3) {
|
||||
["a"]=>
|
||||
string(6) "orange"
|
||||
["b"]=>
|
||||
string(6) "banana"
|
||||
["c"]=>
|
||||
string(5) "apple"
|
||||
}
|
||||
[2]=>
|
||||
array(6) {
|
||||
[0]=>
|
||||
int(1)
|
||||
[1]=>
|
||||
int(2)
|
||||
[2]=>
|
||||
int(3)
|
||||
[3]=>
|
||||
int(4)
|
||||
[4]=>
|
||||
int(5)
|
||||
[5]=>
|
||||
int(6)
|
||||
}
|
||||
}
|
||||
- Sort flag = SORT_REGULAR -
|
||||
bool(true)
|
||||
array(3) {
|
||||
[0]=>
|
||||
array(3) {
|
||||
[0]=>
|
||||
string(5) "first"
|
||||
[5]=>
|
||||
string(6) "second"
|
||||
[6]=>
|
||||
string(5) "third"
|
||||
}
|
||||
[1]=>
|
||||
array(3) {
|
||||
["a"]=>
|
||||
string(6) "orange"
|
||||
["b"]=>
|
||||
string(6) "banana"
|
||||
["c"]=>
|
||||
string(5) "apple"
|
||||
}
|
||||
[2]=>
|
||||
array(6) {
|
||||
[0]=>
|
||||
int(1)
|
||||
[1]=>
|
||||
int(2)
|
||||
[2]=>
|
||||
int(3)
|
||||
[3]=>
|
||||
int(4)
|
||||
[4]=>
|
||||
int(5)
|
||||
[5]=>
|
||||
int(6)
|
||||
}
|
||||
}
|
||||
|
||||
-- Iteration 3 --
|
||||
- With Defualt sort flag -
|
||||
bool(true)
|
||||
array(6) {
|
||||
[0]=>
|
||||
int(1)
|
||||
[1]=>
|
||||
int(1)
|
||||
[2]=>
|
||||
int(1)
|
||||
[3]=>
|
||||
int(1)
|
||||
[4]=>
|
||||
int(13)
|
||||
[5]=>
|
||||
int(19)
|
||||
}
|
||||
- Sort flag = SORT_REGULAR -
|
||||
bool(true)
|
||||
array(6) {
|
||||
[0]=>
|
||||
int(1)
|
||||
[1]=>
|
||||
int(1)
|
||||
[2]=>
|
||||
int(1)
|
||||
[3]=>
|
||||
int(1)
|
||||
[4]=>
|
||||
int(13)
|
||||
[5]=>
|
||||
int(19)
|
||||
}
|
||||
|
||||
-- Iteration 4 --
|
||||
- With Defualt sort flag -
|
||||
bool(true)
|
||||
array(2) {
|
||||
[0]=>
|
||||
string(3) "baz"
|
||||
[1]=>
|
||||
int(1)
|
||||
}
|
||||
- Sort flag = SORT_REGULAR -
|
||||
bool(true)
|
||||
array(2) {
|
||||
[0]=>
|
||||
string(3) "baz"
|
||||
[1]=>
|
||||
int(1)
|
||||
}
|
||||
|
||||
-- Iteration 5 --
|
||||
- With Defualt sort flag -
|
||||
bool(true)
|
||||
array(4) {
|
||||
[0]=>
|
||||
int(1)
|
||||
[1]=>
|
||||
int(5)
|
||||
[2]=>
|
||||
array(1) {
|
||||
["g"]=>
|
||||
int(4)
|
||||
}
|
||||
[3]=>
|
||||
array(2) {
|
||||
["e"]=>
|
||||
int(2)
|
||||
["f"]=>
|
||||
int(3)
|
||||
}
|
||||
}
|
||||
- Sort flag = SORT_REGULAR -
|
||||
bool(true)
|
||||
array(4) {
|
||||
[0]=>
|
||||
int(1)
|
||||
[1]=>
|
||||
int(5)
|
||||
[2]=>
|
||||
array(1) {
|
||||
["g"]=>
|
||||
int(4)
|
||||
}
|
||||
[3]=>
|
||||
array(2) {
|
||||
["e"]=>
|
||||
int(2)
|
||||
["f"]=>
|
||||
int(3)
|
||||
}
|
||||
}
|
||||
Done
|
Loading…
Reference in New Issue
Block a user