array_intersect_variation10.phpt 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. --TEST--
  2. Test array_intersect() function : usage variations - binary safe checking
  3. --FILE--
  4. <?php
  5. /* Prototype : array array_intersect(array $arr1, array $arr2 [, array $...])
  6. * Description: Returns the entries of arr1 that have values which are present in all the other arguments
  7. * Source code: ext/standard/array.c
  8. */
  9. /*
  10. * Testing the behavior of array_intersect() by passing array with
  11. * binary values for $arr1 and $arr2 argument.
  12. */
  13. echo "*** Testing array_intersect() : binary safe checking ***\n";
  14. // array with binary values
  15. $arr_binary = array(b"hello", b"world");
  16. // simple array
  17. $arr_normal = array("hello", "world");
  18. // array with binary value for $arr1 argument
  19. var_dump( array_intersect($arr_binary, $arr_normal) );
  20. // array with binary value for $arr2 argument
  21. var_dump( array_intersect($arr_normal, $arr_binary) );
  22. // array with binary value for both $arr1 and $arr2 argument
  23. var_dump( array_intersect($arr_binary, $arr_binary) );
  24. echo "Done";
  25. ?>
  26. --EXPECTF--
  27. *** Testing array_intersect() : binary safe checking ***
  28. array(2) {
  29. [0]=>
  30. string(5) "hello"
  31. [1]=>
  32. string(5) "world"
  33. }
  34. array(2) {
  35. [0]=>
  36. string(5) "hello"
  37. [1]=>
  38. string(5) "world"
  39. }
  40. array(2) {
  41. [0]=>
  42. string(5) "hello"
  43. [1]=>
  44. string(5) "world"
  45. }
  46. Done