|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2008-04-24 21:41 UTC] dmitrij at stepanov dot lv
Description: ------------ array_key_exists() does not accept float as a key. (The first argument should be either a string or an integer), however it is possible to use floats as keys. Reproduce code: --------------- $array =array( 3.15 =>20); var_dump( array_key_exists( 3.15, $array)) ."\n";// ERROR: The first argument should be either a string or an integer echo $array[3.15];//OK Expected result: ---------------- boolean(true) 20 Actual result: -------------- blahblahblah 20 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 06 16:00:01 2025 UTC |
Negative! Says the documentation: "A key may be either an integer or a string... Floats in key are truncated to integer." $ php -r '$a[2.3] = "foo"; var_dump($a);' array(1) { [2]=> string(3) "foo" }