Edit report at https://bugs.php.net/bug.php?id=60426&edit=1
ID: 60426 Updated by: larue...@php.net Reported by: damiannohales at gmail dot com Summary: array_keys convert keys type -Status: Open +Status: Bogus Type: Bug Package: Arrays related Operating System: Ubuntu PHP Version: Irrelevant Block user comment: N Private report: N New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php " A key may be either an integer or a string. If a key is the standard representation of an integer, it will be interpreted as such (i.e. "8" will be interpreted as 8, while "08" will be interpreted as "08"). " http://www.php.net/manual/en/language.types.array.php Previous Comments: ------------------------------------------------------------------------ [2011-12-01 14:26:49] damiannohales at gmail dot com Description: ------------ I noticed when I extract the keys of an array using array_keys, if a key is an string with a number, on the resulting array from the array_keys execution I get an integer for this key instead of a string. My version of PHP is 5.3.5-1ubuntu7.3. Regards! Test script: --------------- $a = array( '1' => 'apple', '2' => 'banana', '3' => 'orange', '4' => 'stawberry', ); $keys = array_keys($a); echo gettype( $keys[0] ); Expected result: ---------------- Output: string Actual result: -------------- Output integer ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=60426&edit=1