1--TEST--
2Test ksort() function : usage variations - sort heredoc strings
3--FILE--
4<?php
5/* Prototype  : bool ksort ( array &$array [, int $sort_flags] )
6 * Description: Sort an array by key, maintaining key to data correlation
7 * Source code: ext/standard/array.c
8*/
9
10/*
11 * testing ksort() 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 ksort() : 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 ksort() by supplying heredoc string array, 'flag' value is defualt --\n";
41$temp_array = $array;
42var_dump(ksort($temp_array) ); // expecting : bool(true)
43var_dump($temp_array);
44
45echo "\n-- Testing ksort() by supplying heredoc string array, 'flag' = SORT_REGULAR --\n";
46$temp_array = $array;
47var_dump(ksort($temp_array, SORT_REGULAR) ); // expecting : bool(true)
48var_dump($temp_array);
49
50echo "\n-- Testing ksort() by supplying heredoc string array, 'flag' = SORT_STRING --\n";
51$temp_array = $array;
52var_dump(ksort($temp_array, SORT_STRING) ); // expecting : bool(true)
53var_dump($temp_array);
54
55echo "Done\n";
56?>
57--EXPECTF--
58*** Testing ksort() : usage variations ***
59
60-- Testing ksort() by supplying heredoc string array, 'flag' value is defualt --
61bool(true)
62array(3) {
63  ["HEREDOC"]=>
64  string(7) "HEREDOC"
65  ["Heredoc"]=>
66  string(7) "Heredoc"
67  ["heredoc string	with!@# and 123
68Test this!!!"]=>
69  string(43) "heredoc string	with!@# and 123
70Test this!!!"
71}
72
73-- Testing ksort() by supplying heredoc string array, 'flag' = SORT_REGULAR --
74bool(true)
75array(3) {
76  ["HEREDOC"]=>
77  string(7) "HEREDOC"
78  ["Heredoc"]=>
79  string(7) "Heredoc"
80  ["heredoc string	with!@# and 123
81Test this!!!"]=>
82  string(43) "heredoc string	with!@# and 123
83Test this!!!"
84}
85
86-- Testing ksort() by supplying heredoc string array, 'flag' = SORT_STRING --
87bool(true)
88array(3) {
89  ["HEREDOC"]=>
90  string(7) "HEREDOC"
91  ["Heredoc"]=>
92  string(7) "Heredoc"
93  ["heredoc string	with!@# and 123
94Test this!!!"]=>
95  string(43) "heredoc string	with!@# and 123
96Test this!!!"
97}
98Done
99