1--TEST-- 2Test chunk_split() function : usage variations - different double quoted values for 'str' argument 3--FILE-- 4<?php 5/* 6* Passing different double quoted strings for 'str' argument to chunk_split() 7* here 'chunklen' is set to 5 and 'ending' is "????" 8*/ 9 10echo "*** Testing chunk_split() : with different double quoted values for 'str' argument ***\n"; 11 12// Initializing variables 13$chunklen = 5; 14$ending = "????"; 15 16// different values for 'str' 17$values = array( 18 "", //empty 19 " ", //space 20 "This is simple string", //regular string 21 "It's string with quotes", //string containing single quote 22 "This contains @ # $ % ^ & chars", //string with special characters 23 "This string\tcontains\rwhite space\nchars", 24 "This is string with 1234 numbers", 25 "This is string with \0 and ".chr(0)."null chars", //for binary safe 26 "This is string with multiple space char", 27 "Testing invalid \k and \m escape char", 28 "This is to check with \\n and \\t" //to ignore \n and \t results 29 30); 31 32// loop through each element of the array for 'str' 33for($count = 0; $count < count($values); $count++) { 34 echo "-- Iteration ".($count+1)." --\n"; 35 var_dump( chunk_split( $values[$count], $chunklen, $ending) ); 36} 37 38echo "Done" 39?> 40--EXPECTF-- 41*** Testing chunk_split() : with different double quoted values for 'str' argument *** 42-- Iteration 1 -- 43string(4) "????" 44-- Iteration 2 -- 45string(5) " ????" 46-- Iteration 3 -- 47string(41) "This ????is si????mple ????strin????g????" 48-- Iteration 4 -- 49string(43) "It's ????strin????g wit????h quo????tes????" 50-- Iteration 5 -- 51string(59) "This ????conta????ins @???? # $ ????% ^ &???? char????s????" 52-- Iteration 6 -- 53string(70) "This ????strin????g con????tains???? 53whit????e spa????ce 54ch????ars????" 55-- Iteration 7 -- 56string(60) "This ????is st????ring ????with ????1234 ????numbe????rs????" 57-- Iteration 8 -- 58string(69) "This ????is st????ring ????with ????%0 and???? %0nul????l cha????rs????" 59-- Iteration 9 -- 60string(90) "This ????is st????ring ????with ???? mu????ltipl????e ???? ????space???? char????" 61-- Iteration 10 -- 62string(69) "Testi????ng in????valid???? \k a????nd \m???? esca????pe ch????ar????" 63-- Iteration 11 -- 64string(59) "This ????is to???? chec????k wit????h \n ????and \????t????" 65Done 66