1--TEST--
2Test stripslashes() function : usage variations - double dimensional arrays
3--FILE--
4<?php
5/* Prototype  : string stripslashes ( string $str )
6 * Description: Returns an un-quoted string
7 * Source code: ext/standard/string.c
8*/
9
10/*
11 * Test stripslashes() with double dimensional arrays
12*/
13
14echo "*** Testing stripslashes() : with double dimensional arrays ***\n";
15
16// initialising the string array
17
18$str_array = array(
19                    array("", array()),
20                    array("", array("")),
21                    array("f\\'oo", "b\\'ar", array("fo\\'o", "b\\'ar")),
22                    array("f\\'oo", "b\\'ar", array("")),
23                    array("f\\'oo", "b\\'ar", array("fo\\'o", "b\\'ar", array(""))),
24                    array("f\\'oo", "b\\'ar", array("fo\\'o", "b\\'ar", array("fo\\'o", "b\\'ar")))
25                  );
26function stripslashes_deep($value)  {
27  $value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value);
28  return $value;
29}
30
31$count = 1;
32// looping to test for all strings in $str_array
33foreach( $str_array as $arr )  {
34  echo "\n-- Iteration $count --\n";
35  var_dump( stripslashes_deep($arr) );
36  $count ++;
37}
38
39echo "Done\n";
40?>
41--EXPECTF--
42*** Testing stripslashes() : with double dimensional arrays ***
43
44-- Iteration 1 --
45array(2) {
46  [0]=>
47  string(0) ""
48  [1]=>
49  array(0) {
50  }
51}
52
53-- Iteration 2 --
54array(2) {
55  [0]=>
56  string(0) ""
57  [1]=>
58  array(1) {
59    [0]=>
60    string(0) ""
61  }
62}
63
64-- Iteration 3 --
65array(3) {
66  [0]=>
67  string(4) "f'oo"
68  [1]=>
69  string(4) "b'ar"
70  [2]=>
71  array(2) {
72    [0]=>
73    string(4) "fo'o"
74    [1]=>
75    string(4) "b'ar"
76  }
77}
78
79-- Iteration 4 --
80array(3) {
81  [0]=>
82  string(4) "f'oo"
83  [1]=>
84  string(4) "b'ar"
85  [2]=>
86  array(1) {
87    [0]=>
88    string(0) ""
89  }
90}
91
92-- Iteration 5 --
93array(3) {
94  [0]=>
95  string(4) "f'oo"
96  [1]=>
97  string(4) "b'ar"
98  [2]=>
99  array(3) {
100    [0]=>
101    string(4) "fo'o"
102    [1]=>
103    string(4) "b'ar"
104    [2]=>
105    array(1) {
106      [0]=>
107      string(0) ""
108    }
109  }
110}
111
112-- Iteration 6 --
113array(3) {
114  [0]=>
115  string(4) "f'oo"
116  [1]=>
117  string(4) "b'ar"
118  [2]=>
119  array(3) {
120    [0]=>
121    string(4) "fo'o"
122    [1]=>
123    string(4) "b'ar"
124    [2]=>
125    array(2) {
126      [0]=>
127      string(4) "fo'o"
128      [1]=>
129      string(4) "b'ar"
130    }
131  }
132}
133Done
134