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