1--TEST--
2Test chunk_split() function : usage variations - single quoted strings for 'str' argument
3--FILE--
4<?php
5/*
6* passing different single quoted strings as 'str' argument to the function
7* 'chunklen' is set to 7 and 'ending' is '):('
8*/
9
10echo "*** Testing chunk_split() : with different single quoted 'str' ***\n";
11
12//Initializing variables
13$chunklen = 7;
14$ending = "):(";
15
16//different single quoted string for 'str'
17$values = array(
18  '',  //empty
19  ' ',  //space
20  'This is simple string',  //regular string
21  'It\'s string with quotes',
22  'This contains @ # $ % ^ & chars',   //special characters
23  'This string\tcontains\rwhite space\nchars',  //with white space chars
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  'This is to check string with ()',
28  '     Testing with    multiple spaces     ',
29  'Testing invalid \k and \m escape char',
30  'This is to check with \\n and \\t'
31);
32
33
34//Loop through each element of values for 'str'
35for($count = 0;$count < count($values);$count++) {
36  echo "-- Iteration $count --\n";
37  var_dump( chunk_split($values[$count], $chunklen, $ending) );
38}
39
40echo "Done"
41?>
42--EXPECT--
43*** Testing chunk_split() : with different single quoted 'str' ***
44-- Iteration 0 --
45string(3) "):("
46-- Iteration 1 --
47string(4) " ):("
48-- Iteration 2 --
49string(30) "This is):( simple):( string):("
50-- Iteration 3 --
51string(35) "It's st):(ring wi):(th quot):(es):("
52-- Iteration 4 --
53string(46) "This co):(ntains ):(@ # $ %):( ^ & ch):(ars):("
54-- Iteration 5 --
55string(59) "This st):(ring\tc):(ontains):(\rwhite):( space\):(nchars):("
56-- Iteration 6 --
57string(47) "This is):( string):( with 1):(234 num):(bers):("
58-- Iteration 7 --
59string(68) "This is):( string):( with \):(0 and "):(.chr(0)):(."null ):(chars):("
60-- Iteration 8 --
61string(74) "This is):( string):( with  ):(  multi):(ple    ):(     sp):(ace cha):(r):("
62-- Iteration 9 --
63string(46) "This is):( to che):(ck stri):(ng with):( ()):("
64-- Iteration 10 --
65string(59) "     Te):(sting w):(ith    ):(multipl):(e space):(s     ):("
66-- Iteration 11 --
67string(55) "Testing):( invali):(d \k an):(d \m es):(cape ch):(ar):("
68-- Iteration 12 --
69string(46) "This is):( to che):(ck with):( \n and):( \t):("
70Done
71