????JFIF??x?x????'
Server IP : 79.136.114.73 / Your IP : 3.135.204.121 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 array_rand() function : usage variation - with associative arrays for 'input' parameter --FILE-- <?php /* Prototype : mixed array_rand(array $input [, int $num_req]) * Description: Return key/keys for random entry/entries in the array * Source code: ext/standard/array.c */ /* * Test behaviour of array_rand() function when associative array is passed to * the 'input' parameter in the function call */ echo "*** Testing array_rand() : with associative arrays ***\n"; // initialise associative arrays $asso_arrays = array( // array with numeric keys /*1*/ array(1 => 'one', 2 => 2, 1234567890 => 'big', -1 => 'negative key', 2.3 => 'float key', 0 => "zero key", 0.2 => 'decimal key', 2e2 => 'exp key1', -2e3 => 'negative exp key'), // array with string keys array('one' => 1, "two" => 2.0, "three" => 'three', '12twelve' => 12.00, "" => 'empty string', " " => "space key"), // array with hexa values as keys /*3*/ array(0xabc => 2748, 0x12f => '303', 0xff => "255", -0xff => "-255"), // array with octal values as keys array(0123 => 83, 0129 => 10, 010 => "8", -0348 => "-28", 0012 => '10'), // array with bool values as keys array(TRUE => '1', true => true, TrUe => "TRUE", FALSE => '0', false => false, FaLsE => "FALSE"), // array with special chars as keys /*6*/ array('##' => "key1", '&$r' => 'key2', '!' => "key3", '<>' =>'key4', "NULL" => 'key5', "\n" => 'newline as key', "\t" => "tab as key", "'" => 'single quote as key', '"' => 'double quote as key', "\0" => "null char as key") ); /* looping to test array_rand() function with different arrays having * different types of keys */ $counter = 1; foreach($asso_arrays as $input) { echo "\n-- Iteration $counter --\n"; // with default argument echo"\nWith default argument\n"; var_dump( array_rand($input) ); // with default and optional arguments echo"\nWith num_req = 1\n"; var_dump( array_rand($input, 1) ); // with $num_req=1 echo"\nWith num_req = 2\n"; var_dump( array_rand($input, 2) ); // with $num_req=2 $counter++; } // end of for loop echo "Done"; ?> --EXPECTREGEX-- \*\*\* Testing array_rand\(\) : with associative arrays \*\*\* -- Iteration 1 -- With default argument int\([012-][12.e]*[23e]*[34]*[5]*[6]*[7]*[8]*[9]*[0]*\) With num_req = 1 int\([012-][12.e]*[23e]*[34]*[5]*[6]*[7]*[8]*[9]*[0]*\) With num_req = 2 array\(2\) { \[0\]=> int\([012-][12.e]*[23e]*[34]*[5]*[6]*[7]*[8]*[9]*[0]*\) \[1\]=> int\([012-][12.e]*[23e]*[34]*[5]*[6]*[7]*[8]*[9]*[0]*\) } -- Iteration 2 -- With default argument string\([0-9]*\) "[ot1 ]*[hnw2]*[eort]*[ew]*[e]*[l]*[v]*[e]*" With num_req = 1 string\([0-9]*\) "[ot1 ]*[hnw2]*[eort]*[ew]*[e]*[l]*[v]*[e]*" With num_req = 2 array\(2\) { \[0\]=> string\([0-9]*\) "[ot1 ]*[hnw2]*[eort]*[ew]*[e]*[l]*[v]*[e]*" \[1\]=> string\([0-9]*\) "[ot1 ]*[hnw2]*[eort]*[ew]*[e]*[l]*[v]*[e]*" } -- Iteration 3 -- With default argument int\([23-]*[2570]*[345]*[58]*\) With num_req = 1 int\([23-]*[2570]*[345]*[58]*\) With num_req = 2 array\(2\) { \[0\]=> int\([23-]*[2570]*[345]*[58]*\) \[1\]=> int\([23-]*[2570]*[345]*[58]*\) } -- Iteration 4 -- With default argument int\([18-]*[023]*[8]*\) With num_req = 1 int\([18-]*[023]*[8]*\) With num_req = 2 array\(2\) { \[0\]=> int\([18-]*[023]*[8]*\) \[1\]=> int\([18-]*[023]*[8]*\) } -- Iteration 5 -- With default argument int\([01]\) With num_req = 1 int\([01]\) With num_req = 2 array\(2\) { \[0\]=> int\([01]\) \[1\]=> int\([01]\) } -- Iteration 6 -- With default argument string\([0-9]*\) "[#&!N <\n\t'"\0]*[U#$>]*[rL]*[L]*" With num_req = 1 string\([0-9]*\) "[#&!N <\n\t'"\0]*[U#$>]*[rL]*[L]*" With num_req = 2 array\(2\) { \[0\]=> string\([0-9]*\) "[#&!N <\n\t'"\0]*[U#$>]*[rL]*[L]*" \[1\]=> string\([0-9]*\) "[#&!N <\n\t'"\0]*[U#$>]*[rL]*[L]*" } Done