array_unique_variation6.phpt 928 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. --TEST--
  2. Test array_unique() function : usage variations - array with reference variables
  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. * array having reference variables as values.
  12. */
  13. echo "*** Testing array_unique() : array with reference variables for \$input argument ***\n";
  14. $value1 = 10;
  15. $value2 = "hello";
  16. $value3 = 0;
  17. $value4 = &$value2;
  18. // input array containing elements as reference variables
  19. $input = array(
  20. 0 => 0,
  21. 1 => &$value4,
  22. 2 => &$value2,
  23. 3 => "hello",
  24. 4 => &$value3,
  25. 5 => $value4
  26. );
  27. var_dump( array_unique($input, SORT_STRING) );
  28. echo "Done";
  29. ?>
  30. --EXPECTF--
  31. *** Testing array_unique() : array with reference variables for $input argument ***
  32. array(2) {
  33. [0]=>
  34. int(0)
  35. [1]=>
  36. &%unicode|string%(5) "hello"
  37. }
  38. Done