1--TEST--
2Test array_fill_keys() function : variation of parameter
3--FILE--
4<?php
5/* Prototype  : proto array array_fill_keys(array keys, mixed val)
6 * Description: Create an array using the elements of the first parameter as keys each initialized to val
7 * Source code: ext/standard/array.c
8 * Alias to functions:
9 */
10
11
12echo "*** Testing array_fill_keys() : parameter variations ***\n";
13
14$nullVal = null;
15$simpleStr = "simple";
16$fp = fopen(__FILE__, "r");
17$emptyArr = array();
18$bool = false;
19$float = 2.4;
20
21class classA {
22  public function __toString() { return "Class A object"; }
23}
24$obj = new classA();
25
26
27echo "\n-- Testing array_fill_keys() function with empty arguments --\n";
28var_dump( array_fill_keys($emptyArr, $nullVal) );
29
30echo "\n-- Testing array_fill_keys() function with keyed array --\n";
31$keyedArray = array("two" => 2, "strk1" => "strv1", 4, $simpleStr);
32var_dump( array_fill_keys($keyedArray, $simpleStr) );
33
34echo "\n-- Testing array_fill_keys() function with mixed array --\n";
35$mixedArray = array($fp, $obj, $simpleStr, $emptyArr, 2, $bool, $float);
36var_dump( array_fill_keys($mixedArray, $simpleStr) );
37
38fclose($fp);
39echo "Done";
40?>
41--EXPECTF--
42*** Testing array_fill_keys() : parameter variations ***
43
44-- Testing array_fill_keys() function with empty arguments --
45array(0) {
46}
47
48-- Testing array_fill_keys() function with keyed array --
49array(4) {
50  [2]=>
51  string(6) "simple"
52  ["strv1"]=>
53  string(6) "simple"
54  [4]=>
55  string(6) "simple"
56  ["simple"]=>
57  string(6) "simple"
58}
59
60-- Testing array_fill_keys() function with mixed array --
61
62Notice: Array to string conversion in %sarray_fill_keys_variation1.php on line %d
63array(7) {
64  ["Resource id #%d"]=>
65  string(6) "simple"
66  ["Class A object"]=>
67  string(6) "simple"
68  ["simple"]=>
69  string(6) "simple"
70  ["Array"]=>
71  string(6) "simple"
72  [2]=>
73  string(6) "simple"
74  [""]=>
75  string(6) "simple"
76  ["2.4"]=>
77  string(6) "simple"
78}
79Done
80