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