array_unique_variation8.phpt 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. --TEST--
  2. Test array_unique() function : usage variations - two dimensional arrays
  3. --FILE--
  4. <?php
  5. /* Prototype : array array_unique(array $input)
  6. * Description: Removes duplicate values from array
  7. * Source code: ext/standard/array.c
  8. */
  9. /*
  10. * Testing the functionality of array_unique() by passing
  11. * two dimensional arrays for $input argument.
  12. */
  13. echo "*** Testing array_unique() : two dimensional array for \$input argument ***\n";
  14. // initialize the 2-d array
  15. $input = array(
  16. array(1, 2, 3, 1),
  17. array("hello", "world", "str1" => "hello", "str2" => 'world'),
  18. array(1 => "one", 2 => "two", "one", 'two'),
  19. array(1, 2, 3, 1)
  20. );
  21. var_dump( array_unique($input, SORT_STRING) );
  22. echo "Done";
  23. ?>
  24. --EXPECTF--
  25. *** Testing array_unique() : two dimensional array for $input argument ***
  26. Notice: Array to string conversion in %sarray_unique_variation8.php on line %d
  27. Notice: Array to string conversion in %sarray_unique_variation8.php on line %d
  28. Notice: Array to string conversion in %sarray_unique_variation8.php on line %d
  29. Notice: Array to string conversion in %sarray_unique_variation8.php on line %d
  30. array(1) {
  31. [0]=>
  32. array(4) {
  33. [0]=>
  34. int(1)
  35. [1]=>
  36. int(2)
  37. [2]=>
  38. int(3)
  39. [3]=>
  40. int(1)
  41. }
  42. }
  43. Done