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