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