diff options
author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2013-03-14 05:42:27 +0000 |
---|---|---|
committer | <> | 2013-04-03 16:25:08 +0000 |
commit | c4dd7a1a684490673e25aaf4fabec5df138854c4 (patch) | |
tree | 4d57c44caae4480efff02b90b9be86f44bf25409 /ext/standard/tests/array/array_combine_basic.phpt | |
download | php2-master.tar.gz |
Imported from /home/lorry/working-area/delta_php2/php-5.4.13.tar.bz2.HEADphp-5.4.13master
Diffstat (limited to 'ext/standard/tests/array/array_combine_basic.phpt')
-rw-r--r-- | ext/standard/tests/array/array_combine_basic.phpt | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/ext/standard/tests/array/array_combine_basic.phpt b/ext/standard/tests/array/array_combine_basic.phpt new file mode 100644 index 0000000..5d855cf --- /dev/null +++ b/ext/standard/tests/array/array_combine_basic.phpt @@ -0,0 +1,52 @@ +--TEST-- +Test array_combine() function : basic functionality +--FILE-- +<?php +/* Prototype : array array_combine(array $keys, array $values) + * Description: Creates an array by using the elements of the first parameter as keys + * and the elements of the second as the corresponding values + * Source code: ext/standard/array.c +*/ + +echo "*** Testing array_combine() : basic functionality ***\n"; + +/* Different arrays for $keys and $values arguments */ + +// array with default keys for $keys and $values arguments +$keys_array = array(1, 2); +$values_array = array(3,4); +var_dump( array_combine($keys_array, $values_array) ); + +// associative arrays for $keys and $values arguments +$keys_array = array(1 => "a", 2 => 'b'); +$values_array = array(3 => 'c', 4 => "d"); +var_dump( array_combine($keys_array, $values_array) ); + +// mixed array for $keys and $values arguments +$keys_array = array(1, 2 => "b"); +$values_array = array(3 => 'c', 4); +var_dump( array_combine($keys_array, $values_array) ); + +echo "Done"; +?> +--EXPECTF-- +*** Testing array_combine() : basic functionality *** +array(2) { + [1]=> + int(3) + [2]=> + int(4) +} +array(2) { + ["a"]=> + string(1) "c" + ["b"]=> + string(1) "d" +} +array(2) { + [1]=> + string(1) "c" + ["b"]=> + int(4) +} +Done |