1--TEST--
2Test krsort() function : usage variations - sort heredoc strings
3--FILE--
4<?php
5/* Prototype  : bool krsort ( array &$array [, int $sort_flags] )
6 * Description: Sort an array by key in reverse order, maintaining key to data correlation
7 * Source code: ext/standard/array.c
8*/
9
10/*
11 * testing krsort() by providing array of heredoc strings for $array argument with
12 * following flag values:
13 *  1.flag value as defualt
14 *  2.SORT_REGULAR - compare items normally
15 *  3.SORT_STRING  - compare items as strings
16*/
17
18echo "*** Testing krsort() : usage variations ***\n";
19
20// Different heredoc strings to be sorted
21$simple_heredoc1 =<<<EOT
22Heredoc
23EOT;
24
25$simple_heredoc2 =<<<EOT
26HEREDOC
27EOT;
28
29$multiline_heredoc =<<<EOT
30heredoc string\twith!@# and 123
31Test this!!!
32EOT;
33
34$array = array (
35  $simple_heredoc1 => "Heredoc",
36  $simple_heredoc2 => "HEREDOC",
37  $multiline_heredoc => "heredoc string\twith!@# and 123\nTest this!!!"
38);
39
40echo "\n-- Testing krsort() by supplying heredoc string array, 'flag' value is defualt --\n";
41$temp_array = $array;
42var_dump(krsort($temp_array) ); // expecting : bool(true)
43var_dump($temp_array);
44
45echo "\n-- Testing krsort() by supplying heredoc string array, 'flag' = SORT_REGULAR --\n";
46$temp_array = $array;
47var_dump(krsort($temp_array, SORT_REGULAR) ); // expecting : bool(true)
48var_dump($temp_array);
49
50echo "\n-- Testing krsort() by supplying heredoc string array, 'flag' = SORT_STRING --\n";
51$temp_array = $array;
52var_dump(krsort($temp_array, SORT_STRING) ); // expecting : bool(true)
53var_dump($temp_array);
54
55echo "Done\n";
56?>
57--EXPECTF--
58*** Testing krsort() : usage variations ***
59
60-- Testing krsort() by supplying heredoc string array, 'flag' value is defualt --
61bool(true)
62array(3) {
63  ["heredoc string	with!@# and 123
64Test this!!!"]=>
65  string(43) "heredoc string	with!@# and 123
66Test this!!!"
67  ["Heredoc"]=>
68  string(7) "Heredoc"
69  ["HEREDOC"]=>
70  string(7) "HEREDOC"
71}
72
73-- Testing krsort() by supplying heredoc string array, 'flag' = SORT_REGULAR --
74bool(true)
75array(3) {
76  ["heredoc string	with!@# and 123
77Test this!!!"]=>
78  string(43) "heredoc string	with!@# and 123
79Test this!!!"
80  ["Heredoc"]=>
81  string(7) "Heredoc"
82  ["HEREDOC"]=>
83  string(7) "HEREDOC"
84}
85
86-- Testing krsort() by supplying heredoc string array, 'flag' = SORT_STRING --
87bool(true)
88array(3) {
89  ["heredoc string	with!@# and 123
90Test this!!!"]=>
91  string(43) "heredoc string	with!@# and 123
92Test this!!!"
93  ["Heredoc"]=>
94  string(7) "Heredoc"
95  ["HEREDOC"]=>
96  string(7) "HEREDOC"
97}
98Done
99