array_combine_variation6.phpt 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. --TEST--
  2. Test array_combine() function : usage variations - binary safe checking
  3. --FILE--
  4. <?php
  5. /* Prototype : array array_combine(array $keys, array $values)
  6. * Description: Creates an array by using the elements of the first parameter as keys
  7. * and the elements of the second as the corresponding values
  8. * Source code: ext/standard/array.c
  9. */
  10. /*
  11. * Testing the behavior of array_combine() by passing array with
  12. * binary values for $keys and $values argument.
  13. */
  14. echo "*** Testing array_combine() : binary safe checking ***\n";
  15. // array with binary values
  16. $arr_binary = array(b"hello", b"world");
  17. $arr_normal = array("hello", "world");
  18. // array with binary value for $keys and $values argument
  19. var_dump( array_combine($arr_binary, $arr_binary) );
  20. // array with binary value for $values argument
  21. var_dump( array_combine($arr_normal, $arr_binary) );
  22. // array with binary value for $keys argument
  23. var_dump( array_combine($arr_binary, $arr_normal) );
  24. echo "Done";
  25. ?>
  26. --EXPECTF--
  27. *** Testing array_combine() : binary safe checking ***
  28. array(2) {
  29. ["hello"]=>
  30. string(5) "hello"
  31. ["world"]=>
  32. string(5) "world"
  33. }
  34. array(2) {
  35. ["hello"]=>
  36. string(5) "hello"
  37. ["world"]=>
  38. string(5) "world"
  39. }
  40. array(2) {
  41. ["hello"]=>
  42. string(5) "hello"
  43. ["world"]=>
  44. string(5) "world"
  45. }
  46. Done