import zend standard tests
[hiphop-php.git] / hphp / test / zend / bad / ext-standard-array / array_multisort_variation2.php
blobe677f86b8ceffcc7e8df0a638107ecbe3b36f4f0
1 <?php
2 /* Prototype : bool array_multisort(array ar1 [, SORT_ASC|SORT_DESC [, SORT_REGULAR|SORT_NUMERIC|SORT_STRING|SORT_NATURAL|SORT_FLAG_CASE]] [, array ar2 [, SORT_ASC|SORT_DESC [, SORT_REGULAR|SORT_NUMERIC|SORT_STRING|SORT_NATURAL|SORT_FLAG_CASE]], ...])
3 * Description: Sort multiple arrays at once similar to how ORDER BY clause works in SQL
4 * Source code: ext/standard/array.c
5 * Alias to functions:
6 */
8 echo "*** Testing array_multisort() : usage variation ***\n";
10 // Define error handler
11 function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
12 if (error_reporting() != 0) {
13 // report non-silenced errors
14 echo "Error: $err_no - $err_msg, $filename($linenum)\n";
17 set_error_handler('test_error_handler');
19 // Initialise function arguments not being substituted (if any)
20 $ar1 = array(1, 2);
21 $ar2 = array(1, 2);
23 //get an unset variable
24 $unset_var = 10;
25 unset ($unset_var);
27 // define some classes
28 class classWithToString
30 public function __toString() {
31 return "Class A object";
35 class classWithoutToString
39 // heredoc string
40 $heredoc = <<<EOT
41 hello world
42 EOT;
44 // add arrays
45 $index_array = array (1, 2, 3);
46 $assoc_array = array ('one' => 1, 'two' => 2);
48 //array of values to iterate over
49 $inputs = array(
51 // int data
52 'int 0' => 0,
53 'int 1' => 1,
54 'int 12345' => 12345,
55 'int -12345' => -2345,
57 // float data
58 'float 10.5' => 10.5,
59 'float -10.5' => -10.5,
60 'float 12.3456789000e10' => 12.3456789000e10,
61 'float -12.3456789000e10' => -12.3456789000e10,
62 'float .5' => .5,
64 // array data
65 'empty array' => array(),
66 'int indexed array' => $index_array,
67 'associative array' => $assoc_array,
68 'nested arrays' => array('foo', $index_array, $assoc_array),
70 // null data
71 'uppercase NULL' => NULL,
72 'lowercase null' => null,
74 // boolean data
75 'lowercase true' => true,
76 'lowercase false' =>false,
77 'uppercase TRUE' =>TRUE,
78 'uppercase FALSE' =>FALSE,
80 // empty data
81 'empty string DQ' => "",
82 'empty string SQ' => '',
84 // string data
85 'string DQ' => "string",
86 'string SQ' => 'string',
87 'mixed case string' => "sTrInG",
88 'heredoc' => $heredoc,
90 // object data
91 'instance of classWithToString' => new classWithToString(),
92 'instance of classWithoutToString' => new classWithoutToString(),
94 // undefined data
95 'undefined var' => @$undefined_var,
97 // unset data
98 'unset var' => @$unset_var,
101 // loop through each element of the array for SORT_REGULAR|SORT_NUMERIC|SORT_STRING|SORT_NATURAL|SORT_FLAG_CASE]]
103 foreach($inputs as $key =>$value) {
104 echo "\n--$key--\n";
105 var_dump( array_multisort($ar1, $value) );
109 ===DONE===