1--TEST--
2Test array_key_exists() function : usage variations - floats and casting to ints
3--FILE--
4<?php
5/* Prototype  : bool array_key_exists(mixed $key, array $search)
6 * Description: Checks if the given key or index exists in the array
7 * Source code: ext/standard/array.c
8 * Alias to functions: key_exists
9 */
10
11/*
12 * Pass floats as $key argument, then cast float values
13 * to integers and pass as $key argument
14 */
15
16echo "*** Testing array_key_exists() : usage variations ***\n";
17
18$keys = array(1.2345678900E-10, 1.00000000000001, 1.99999999999999);
19
20$search = array ('zero', 'one', 'two');
21
22$iterator = 1;
23foreach($keys as $key) {
24	echo "\n-- Iteration $iterator --\n";
25	echo "Pass float as \$key:\n";
26	var_dump(array_key_exists($key, $search));
27	echo "Cast float to int:\n";
28	var_dump(array_key_exists((int)$key, $search));
29}
30
31echo "Done";
32?>
33--EXPECTF--
34*** Testing array_key_exists() : usage variations ***
35
36-- Iteration 1 --
37Pass float as $key:
38
39Warning: array_key_exists(): The first argument should be either a string or an integer in %s on line %d
40bool(false)
41Cast float to int:
42bool(true)
43
44-- Iteration 1 --
45Pass float as $key:
46
47Warning: array_key_exists(): The first argument should be either a string or an integer in %s on line %d
48bool(false)
49Cast float to int:
50bool(true)
51
52-- Iteration 1 --
53Pass float as $key:
54
55Warning: array_key_exists(): The first argument should be either a string or an integer in %s on line %d
56bool(false)
57Cast float to int:
58bool(true)
59Done
60