Annotation of embedaddon/php/ext/standard/tests/array/array_combine_basic.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Test array_combine() function : basic functionality
! 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: echo "*** Testing array_combine() : basic functionality ***\n";
! 12:
! 13: /* Different arrays for $keys and $values arguments */
! 14:
! 15: // array with default keys for $keys and $values arguments
! 16: $keys_array = array(1, 2);
! 17: $values_array = array(3,4);
! 18: var_dump( array_combine($keys_array, $values_array) );
! 19:
! 20: // associative arrays for $keys and $values arguments
! 21: $keys_array = array(1 => "a", 2 => 'b');
! 22: $values_array = array(3 => 'c', 4 => "d");
! 23: var_dump( array_combine($keys_array, $values_array) );
! 24:
! 25: // mixed array for $keys and $values arguments
! 26: $keys_array = array(1, 2 => "b");
! 27: $values_array = array(3 => 'c', 4);
! 28: var_dump( array_combine($keys_array, $values_array) );
! 29:
! 30: echo "Done";
! 31: ?>
! 32: --EXPECTF--
! 33: *** Testing array_combine() : basic functionality ***
! 34: array(2) {
! 35: [1]=>
! 36: int(3)
! 37: [2]=>
! 38: int(4)
! 39: }
! 40: array(2) {
! 41: ["a"]=>
! 42: string(1) "c"
! 43: ["b"]=>
! 44: string(1) "d"
! 45: }
! 46: array(2) {
! 47: [1]=>
! 48: string(1) "c"
! 49: ["b"]=>
! 50: int(4)
! 51: }
! 52: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>