array_values.phpt 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. --TEST--
  2. Test array_values() function
  3. --INI--
  4. precision=14
  5. --FILE--
  6. <?php
  7. echo "*** Testing array_values() on basic array ***\n";
  8. $basic_arr = array( 1, 2, 2.0, "asdasd", array(1,2,3) );
  9. var_dump( array_values($basic_arr) );
  10. echo "\n*** Testing array_values() on various arrays ***";
  11. $arrays = array (
  12. array(),
  13. array(0),
  14. array(-1),
  15. array( array() ),
  16. array("Hello"),
  17. array(""),
  18. array("", array()),
  19. array(1,2,3),
  20. array(1,2,3, array()),
  21. array(1,2,3, array(4,6)),
  22. array("a" => 1, "b" => 2, "c" =>3),
  23. array(0 => 0, 1 => 1, 2 => 2),
  24. array(TRUE, FALSE, NULL, true, false, null, "TRUE", "FALSE",
  25. "NULL", "\x000", "\000"),
  26. array("Hi" => 1, "Hello" => 2, "World" => 3),
  27. array("a" => "abcd", "a" => "", "ab" => -6, "cd" => -0.5 ),
  28. array(0 => array(), 1=> array(0), 2 => array(1), ""=> array(), ""=>"" )
  29. );
  30. $i = 0;
  31. /* loop through to test array_values() with different arrays given above */
  32. foreach ($arrays as $array) {
  33. echo "\n-- Iteration $i --\n";
  34. var_dump( array_values($array) );
  35. $i++;
  36. }
  37. echo "Done\n";
  38. ?>
  39. --EXPECTF--
  40. *** Testing array_values() on basic array ***
  41. array(5) {
  42. [0]=>
  43. int(1)
  44. [1]=>
  45. int(2)
  46. [2]=>
  47. float(2)
  48. [3]=>
  49. string(6) "asdasd"
  50. [4]=>
  51. array(3) {
  52. [0]=>
  53. int(1)
  54. [1]=>
  55. int(2)
  56. [2]=>
  57. int(3)
  58. }
  59. }
  60. *** Testing array_values() on various arrays ***
  61. -- Iteration 0 --
  62. array(0) {
  63. }
  64. -- Iteration 1 --
  65. array(1) {
  66. [0]=>
  67. int(0)
  68. }
  69. -- Iteration 2 --
  70. array(1) {
  71. [0]=>
  72. int(-1)
  73. }
  74. -- Iteration 3 --
  75. array(1) {
  76. [0]=>
  77. array(0) {
  78. }
  79. }
  80. -- Iteration 4 --
  81. array(1) {
  82. [0]=>
  83. string(5) "Hello"
  84. }
  85. -- Iteration 5 --
  86. array(1) {
  87. [0]=>
  88. string(0) ""
  89. }
  90. -- Iteration 6 --
  91. array(2) {
  92. [0]=>
  93. string(0) ""
  94. [1]=>
  95. array(0) {
  96. }
  97. }
  98. -- Iteration 7 --
  99. array(3) {
  100. [0]=>
  101. int(1)
  102. [1]=>
  103. int(2)
  104. [2]=>
  105. int(3)
  106. }
  107. -- Iteration 8 --
  108. array(4) {
  109. [0]=>
  110. int(1)
  111. [1]=>
  112. int(2)
  113. [2]=>
  114. int(3)
  115. [3]=>
  116. array(0) {
  117. }
  118. }
  119. -- Iteration 9 --
  120. array(4) {
  121. [0]=>
  122. int(1)
  123. [1]=>
  124. int(2)
  125. [2]=>
  126. int(3)
  127. [3]=>
  128. array(2) {
  129. [0]=>
  130. int(4)
  131. [1]=>
  132. int(6)
  133. }
  134. }
  135. -- Iteration 10 --
  136. array(3) {
  137. [0]=>
  138. int(1)
  139. [1]=>
  140. int(2)
  141. [2]=>
  142. int(3)
  143. }
  144. -- Iteration 11 --
  145. array(3) {
  146. [0]=>
  147. int(0)
  148. [1]=>
  149. int(1)
  150. [2]=>
  151. int(2)
  152. }
  153. -- Iteration 12 --
  154. array(11) {
  155. [0]=>
  156. bool(true)
  157. [1]=>
  158. bool(false)
  159. [2]=>
  160. NULL
  161. [3]=>
  162. bool(true)
  163. [4]=>
  164. bool(false)
  165. [5]=>
  166. NULL
  167. [6]=>
  168. string(4) "TRUE"
  169. [7]=>
  170. string(5) "FALSE"
  171. [8]=>
  172. string(4) "NULL"
  173. [9]=>
  174. string(2) "%00"
  175. [10]=>
  176. string(1) "%0"
  177. }
  178. -- Iteration 13 --
  179. array(3) {
  180. [0]=>
  181. int(1)
  182. [1]=>
  183. int(2)
  184. [2]=>
  185. int(3)
  186. }
  187. -- Iteration 14 --
  188. array(3) {
  189. [0]=>
  190. string(0) ""
  191. [1]=>
  192. int(-6)
  193. [2]=>
  194. float(-0.5)
  195. }
  196. -- Iteration 15 --
  197. array(4) {
  198. [0]=>
  199. array(0) {
  200. }
  201. [1]=>
  202. array(1) {
  203. [0]=>
  204. int(0)
  205. }
  206. [2]=>
  207. array(1) {
  208. [0]=>
  209. int(1)
  210. }
  211. [3]=>
  212. string(0) ""
  213. }
  214. Done