1--TEST--
2Test array_key_exists() function : usage variations - floats and casting to ints
3--FILE--
4<?php
5/*
6 * Pass floats as $key argument, then cast float values
7 * to integers and pass as $key argument
8 */
9
10echo "*** Testing array_key_exists() : usage variations ***\n";
11
12$keys = array(1.2345678900E-10, 1.00000000000001, 1.99999999999999);
13
14$search = array ('zero', 'one', 'two');
15
16$iterator = 1;
17foreach($keys as $key) {
18    echo "\n-- Iteration $iterator --\n";
19    echo "Pass float as \$key:\n";
20    try {
21        var_dump(array_key_exists($key, $search));
22    } catch (TypeError $exception) {
23        echo $exception->getMessage() . "\n";
24    }
25    echo "Cast float to int:\n";
26    var_dump(array_key_exists((int)$key, $search));
27}
28
29echo "Done";
30?>
31--EXPECT--
32*** Testing array_key_exists() : usage variations ***
33
34-- Iteration 1 --
35Pass float as $key:
36bool(true)
37Cast float to int:
38bool(true)
39
40-- Iteration 1 --
41Pass float as $key:
42bool(true)
43Cast float to int:
44bool(true)
45
46-- Iteration 1 --
47Pass float as $key:
48bool(true)
49Cast float to int:
50bool(true)
51Done
52