1--TEST--
2Test nl2br() function : usage variations - double quoted strings for 'str' argument
3--FILE--
4<?php
5/* Test nl2br() function by passing double quoted strings containing various
6 *   combinations of new line chars to 'str' argument
7*/
8
9echo "*** Testing nl2br() : usage variations ***\n";
10
11$strings = array(
12  //new line chars embedded in strings
13  "Hello\nWorld",
14  "\nHello\nWorld\n",
15  "Hello\rWorld",
16  "\rHello\rWorld\r",
17  "Hello\r\nWorld",
18  "\r\nHello\r\nWorld\r\n",
19
20  //one blank line
21  "
22",
23
24  //two blank lines
25  "
26
27",
28
29  //inserted new line in a string
30  "Hello
31World"
32);
33
34//loop through $strings array to test nl2br() function with each element
35$count = 1;
36foreach( $strings as $str ){
37  echo "-- Iteration $count --\n";
38  var_dump(nl2br($str) );
39  $count ++ ;
40}
41echo "Done";
42?>
43--EXPECT--
44*** Testing nl2br() : usage variations ***
45-- Iteration 1 --
46string(17) "Hello<br />
47World"
48-- Iteration 2 --
49string(31) "<br />
50Hello<br />
51World<br />
52"
53-- Iteration 3 --
54string(17) "Hello<br />
54World"
55-- Iteration 4 --
56string(31) "<br />
56Hello<br />
56World<br />
56"
57-- Iteration 5 --
58string(18) "Hello<br />
59World"
60-- Iteration 6 --
61string(34) "<br />
62Hello<br />
63World<br />
64"
65-- Iteration 7 --
66string(7) "<br />
67"
68-- Iteration 8 --
69string(14) "<br />
70<br />
71"
72-- Iteration 9 --
73string(17) "Hello<br />
74World"
75Done
76