extract_variation5.phpt 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. --TEST--
  2. Test extract() function (variation 5)
  3. --FILE--
  4. <?php
  5. $mixed_array = array(
  6. array( array("oNe", "tWo", 4), array(10, 20, 30, 40, 50), array() ),
  7. array( "one" => 1, "one" => 2, "three" => 3, 3, 4, 3 => 33, 4 => 44, 5, 6,
  8. 5 => 57, "5.4" => 554, "5.7" => 557 )
  9. );
  10. $counter = 0;
  11. foreach ( $mixed_array as $sub_array ) {
  12. echo "\n-- Iteration $counter --\n";
  13. $counter++;
  14. var_dump ( extract($sub_array)); /* Single Argument */
  15. /* variations of two arguments */
  16. var_dump ( extract($sub_array, EXTR_OVERWRITE));
  17. var_dump ( extract($sub_array, EXTR_SKIP));
  18. var_dump ( extract($sub_array, EXTR_IF_EXISTS));
  19. /* variations of three arguments with use of various extract types*/
  20. var_dump ( extract($sub_array, EXTR_PREFIX_INVALID, "ssd"));
  21. var_dump ( extract($sub_array, EXTR_PREFIX_SAME, "sss"));
  22. var_dump ( extract($sub_array, EXTR_PREFIX_ALL, "bb"));
  23. var_dump ( extract($sub_array, EXTR_PREFIX_ALL, "")); // "_" taken as default prefix
  24. var_dump ( extract($sub_array, EXTR_PREFIX_IF_EXISTS, "bb"));
  25. }
  26. echo "Done\n";
  27. ?>
  28. --EXPECT--
  29. -- Iteration 0 --
  30. int(0)
  31. int(0)
  32. int(0)
  33. int(0)
  34. int(3)
  35. int(0)
  36. int(3)
  37. int(3)
  38. int(0)
  39. -- Iteration 1 --
  40. int(2)
  41. int(2)
  42. int(0)
  43. int(2)
  44. int(8)
  45. int(2)
  46. int(8)
  47. int(8)
  48. int(2)
  49. Done