1--TEST-- 2Test ksort() function : usage variations - sort heredoc strings 3--FILE-- 4<?php 5/* 6 * testing ksort() 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 ksort() : 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 ksort() by supplying heredoc string array, 'flag' value is default --\n"; 36$temp_array = $array; 37var_dump(ksort($temp_array) ); // expecting : bool(true) 38var_dump($temp_array); 39 40echo "\n-- Testing ksort() by supplying heredoc string array, 'flag' = SORT_REGULAR --\n"; 41$temp_array = $array; 42var_dump(ksort($temp_array, SORT_REGULAR) ); // expecting : bool(true) 43var_dump($temp_array); 44 45echo "\n-- Testing ksort() by supplying heredoc string array, 'flag' = SORT_STRING --\n"; 46$temp_array = $array; 47var_dump(ksort($temp_array, SORT_STRING) ); // expecting : bool(true) 48var_dump($temp_array); 49 50echo "Done\n"; 51?> 52--EXPECT-- 53*** Testing ksort() : usage variations *** 54 55-- Testing ksort() by supplying heredoc string array, 'flag' value is default -- 56bool(true) 57array(3) { 58 ["HEREDOC"]=> 59 string(7) "HEREDOC" 60 ["Heredoc"]=> 61 string(7) "Heredoc" 62 ["heredoc string with!@# and 123 63Test this!!!"]=> 64 string(43) "heredoc string with!@# and 123 65Test this!!!" 66} 67 68-- Testing ksort() by supplying heredoc string array, 'flag' = SORT_REGULAR -- 69bool(true) 70array(3) { 71 ["HEREDOC"]=> 72 string(7) "HEREDOC" 73 ["Heredoc"]=> 74 string(7) "Heredoc" 75 ["heredoc string with!@# and 123 76Test this!!!"]=> 77 string(43) "heredoc string with!@# and 123 78Test this!!!" 79} 80 81-- Testing ksort() by supplying heredoc string array, 'flag' = SORT_STRING -- 82bool(true) 83array(3) { 84 ["HEREDOC"]=> 85 string(7) "HEREDOC" 86 ["Heredoc"]=> 87 string(7) "Heredoc" 88 ["heredoc string with!@# and 123 89Test this!!!"]=> 90 string(43) "heredoc string with!@# and 123 91Test this!!!" 92} 93Done 94