1--TEST-- 2Test shuffle() function : usage variation - arrays with diff heredoc strings 3--FILE-- 4<?php 5/* Prototype : bool shuffle(array $array_arg) 6 * Description: Randomly shuffle the contents of an array 7 * Source code: ext/standard/array.c 8*/ 9 10/* 11* Test behaviour of shuffle() when an array of heredoc strings is passed to 12* 'array_arg' argument of the function 13*/ 14 15echo "*** Testing shuffle() : with array containing heredoc strings ***\n"; 16 17// defining different heredoc strings 18$empty_heredoc = <<<EOT 19EOT; 20 21$heredoc_with_newline = <<<EOT 22\n 23EOT; 24 25$heredoc_with_characters = <<<EOT 26first line of heredoc string 27second line of heredoc string 28third line of heredocstring 29EOT; 30 31$heredoc_with_newline_and_tabs = <<<EOT 32hello\tworld\nhello\nworld\n 33EOT; 34 35$heredoc_with_alphanumerics = <<<EOT 36hello123world456 371234hello\t1234 38EOT; 39 40$heredoc_with_embedded_nulls = <<<EOT 41hello\0world\0hello 42\0hello\0 43EOT; 44 45// defining array with values as heredoc strings 46$heredoc_array = array( 47 $empty_heredoc, 48 $heredoc_with_newline, 49 $heredoc_with_characters, 50 $heredoc_with_newline_and_tabs, 51 $heredoc_with_alphanumerics, 52 $heredoc_with_embedded_nulls 53); 54 55// defining array with keys as heredoc strings 56$heredoc_asso_array = array( 57 $empty_heredoc => "heredoc1", 58 $heredoc_with_newline => "heredoc2", 59 $heredoc_with_characters => "heredoc3", 60 $heredoc_with_newline_and_tabs => "heredoc3", 61 $heredoc_with_alphanumerics => "heredoc4", 62 $heredoc_with_embedded_nulls => "heredoc5" 63); 64 65// test shuffle() with array containing heredoc strings as values 66echo "\n-- with array of heredoc strings --\n"; 67var_dump( shuffle($heredoc_array) ); 68echo "\nThe output array is:\n"; 69var_dump( $heredoc_array ); 70 71// test shuffle() with array containing heredoc strings as its keys 72echo "\n-- with array having heredoc strings as keys --\n"; 73var_dump( shuffle($heredoc_asso_array) ); 74echo "\nThe output array is:\n"; 75var_dump( $heredoc_asso_array ); 76 77echo "Done"; 78?> 79--EXPECTREGEX-- 80\*\*\* Testing shuffle\(\) : with array containing heredoc strings \*\*\* 81 82-- with array of heredoc strings -- 83bool\(true\) 84 85The output array is: 86array\(6\) { 87 \[0\]=> 88 string\([0-9]*\) "[0-9 a-z \n \0 \t]*" 89 \[1\]=> 90 string\([0-9]*\) "[0-9 a-z \n \0 \t]*" 91 \[2\]=> 92 string\([0-9]*\) "[0-9 a-z \n \0 \t]*" 93 \[3\]=> 94 string\([0-9]*\) "[0-9 a-z \n \0 \t]*" 95 \[4\]=> 96 string\([0-9]*\) "[0-9 a-z \n \0 \t]*" 97 \[5\]=> 98 string\([0-9]*\) "[0-9 a-z \n \0 \t]*" 99} 100 101-- with array having heredoc strings as keys -- 102bool\(true\) 103 104The output array is: 105array\(6\) { 106 \[0\]=> 107 string\(8\) "[heredoc 1-5]*" 108 \[1\]=> 109 string\(8\) "[heredoc 1-5]*" 110 \[2\]=> 111 string\(8\) "[heredoc 1-5]*" 112 \[3\]=> 113 string\(8\) "[heredoc 1-5]*" 114 \[4\]=> 115 string\(8\) "[heredoc 1-5]*" 116 \[5\]=> 117 string\(8\) "[heredoc 1-5]*" 118} 119Done 120 121