summaryrefslogtreecommitdiff
path: root/ext/standard/tests/strings/chunk_split_variation6.phpt
blob: 4242a81a9b42baa48f872401ea760a5f976fbc8f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
--TEST--
Test chunk_split() function : usage variations - single quoted strings for 'str' argument
--FILE--
<?php
/* Prototype  : string chunk_split(string $str [, int $chunklen [, string $ending]])
 * Description: Returns split line
 * Source code: ext/standard/string.c
 * Alias to functions: none
*/

/*
* passing different single quoted strings as 'str' argument to the function
* 'chunklen' is set to 7 and 'ending' is '):('
*/

echo "*** Testing chunk_split() : with different single quoted 'str' ***\n";

//Initializing variables
$chunklen = 7;
$ending = "):(";

//different single quoted string for 'str'
$values = array(
  '',  //empty
  ' ',  //space
  'This is simple string',  //regular string
  'It\'s string with quotes',
  'This contains @ # $ % ^ & chars',   //special characters
  'This string\tcontains\rwhite space\nchars',  //with white space chars
  'This is string with 1234 numbers',
  'This is string with \0 and ".chr(0)."null chars',  //for binary safe
  'This is string with    multiple         space char',
  'This is to check string with ()',
  '     Testing with    multiple spaces     ',
  'Testing invalid \k and \m escape char',
  'This is to check with \\n and \\t'
);


//Loop through each element of values for 'str'
for($count = 0;$count < count($values);$count++) {
  echo "-- Iteration $count --\n";
  var_dump( chunk_split($values[$count], $chunklen, $ending) );
}

echo "Done"
?>
--EXPECTF--
*** Testing chunk_split() : with different single quoted 'str' ***
-- Iteration 0 --
string(3) "):("
-- Iteration 1 --
string(4) " ):("
-- Iteration 2 --
string(30) "This is):( simple):( string):("
-- Iteration 3 --
string(35) "It's st):(ring wi):(th quot):(es):("
-- Iteration 4 --
string(46) "This co):(ntains ):(@ # $ %):( ^ & ch):(ars):("
-- Iteration 5 --
string(59) "This st):(ring\tc):(ontains):(\rwhite):( space\):(nchars):("
-- Iteration 6 --
string(47) "This is):( string):( with 1):(234 num):(bers):("
-- Iteration 7 --
string(68) "This is):( string):( with \):(0 and "):(.chr(0)):(."null ):(chars):("
-- Iteration 8 --
string(74) "This is):( string):( with  ):(  multi):(ple    ):(     sp):(ace cha):(r):("
-- Iteration 9 --
string(46) "This is):( to che):(ck stri):(ng with):( ()):("
-- Iteration 10 --
string(59) "     Te):(sting w):(ith    ):(multipl):(e space):(s     ):("
-- Iteration 11 --
string(55) "Testing):( invali):(d \k an):(d \m es):(cape ch):(ar):("
-- Iteration 12 --
string(46) "This is):( to che):(ck with):( \n and):( \t):("
Done