????JFIF??x?x????'
Server IP : 79.136.114.73 / Your IP : 3.14.133.138 Web Server : Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.29 OpenSSL/1.0.1f System : Linux b8009 3.13.0-170-generic #220-Ubuntu SMP Thu May 9 12:40:49 UTC 2019 x86_64 User : www-data ( 33) PHP Version : 5.5.9-1ubuntu4.29 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /proc/self/root/home/b8009/php-5.6.22/ext/standard/tests/array/ |
Upload File : |
--TEST-- Test krsort() function : usage variations - sort array with/without key values --FILE-- <?php /* Prototype : bool krsort ( array &$array [, int $sort_flags] ) * Description: Sort an array by key in reverse order, maintaining key to data correlation. * Source code: ext/standard/array.c */ /* * Testing krsort() by providing arrays with/without key values for $array argument * with following flag values: * 1.flag value as defualt * 2.SORT_REGULAR - compare items normally */ echo "*** Testing krsort() : usage variations ***\n"; // list of arrays with/without key values $various_arrays = array ( array(5 => 55, 66, 22, 33, 11), array ("a" => "orange", "banana", "c" => "apple"), array(1, 2, 3, 4, 5, 6), array("first", 5 => "second", 1 => "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 krsort() by supplying various arrays with/without key values --\n"; // loop through to test krsort() with different arrays, foreach ($various_arrays as $array) { echo "\n-- Iteration $count --\n"; echo "- With defualt sort flag -\n"; $temp_array = $array; var_dump( krsort($temp_array) ); var_dump($temp_array); echo "- Sort flag = SORT_REGULAR -\n"; $temp_array = $array; var_dump( krsort($temp_array, SORT_REGULAR) ); var_dump($temp_array); $count++; } echo "Done\n"; ?> --EXPECTF-- *** Testing krsort() : usage variations *** -- Testing krsort() by supplying various arrays with/without key values -- -- Iteration 1 -- - With defualt sort flag - bool(true) array(5) { [9]=> int(11) [8]=> int(33) [7]=> int(22) [6]=> int(66) [5]=> int(55) } - Sort flag = SORT_REGULAR - bool(true) array(5) { [9]=> int(11) [8]=> int(33) [7]=> int(22) [6]=> int(66) [5]=> int(55) } -- Iteration 2 -- - With defualt sort flag - bool(true) array(3) { ["c"]=> string(5) "apple" [0]=> string(6) "banana" ["a"]=> string(6) "orange" } - Sort flag = SORT_REGULAR - bool(true) array(3) { ["c"]=> string(5) "apple" [0]=> string(6) "banana" ["a"]=> string(6) "orange" } -- Iteration 3 -- - With defualt sort flag - bool(true) array(6) { [5]=> int(6) [4]=> int(5) [3]=> int(4) [2]=> int(3) [1]=> int(2) [0]=> int(1) } - Sort flag = SORT_REGULAR - bool(true) array(6) { [5]=> int(6) [4]=> int(5) [3]=> int(4) [2]=> int(3) [1]=> int(2) [0]=> int(1) } -- Iteration 4 -- - With defualt sort flag - bool(true) array(3) { [5]=> string(6) "second" [1]=> string(5) "third" [0]=> string(5) "first" } - Sort flag = SORT_REGULAR - bool(true) array(3) { [5]=> string(6) "second" [1]=> string(5) "third" [0]=> string(5) "first" } -- Iteration 5 -- - With defualt sort flag - bool(true) array(6) { [9]=> int(19) [8]=> int(1) [4]=> int(1) [3]=> int(13) [1]=> int(1) [0]=> int(1) } - Sort flag = SORT_REGULAR - bool(true) array(6) { [9]=> int(19) [8]=> int(1) [4]=> int(1) [3]=> int(13) [1]=> int(1) [0]=> int(1) } -- Iteration 6 -- - With defualt sort flag - bool(true) array(2) { ["foo"]=> int(1) ["bar"]=> string(3) "baz" } - Sort flag = SORT_REGULAR - bool(true) array(2) { ["foo"]=> int(1) ["bar"]=> string(3) "baz" } -- Iteration 7 -- - With defualt sort flag - bool(true) array(4) { ["d"]=> int(5) ["c"]=> array(1) { ["g"]=> int(4) } ["b"]=> array(2) { ["e"]=> int(2) ["f"]=> int(3) } ["a"]=> int(1) } - Sort flag = SORT_REGULAR - bool(true) array(4) { ["d"]=> int(5) ["c"]=> array(1) { ["g"]=> int(4) } ["b"]=> array(2) { ["e"]=> int(2) ["f"]=> int(3) } ["a"]=> int(1) } Done