ID: 35093 Updated by: [EMAIL PROTECTED] Reported By: tony at marston-home dot demon dot co dot uk -Status: Open +Status: Bogus Bug Type: Arrays related Operating System: Windows XP PHP Version: 4.4.1 New Comment:
Please do not submit the same bug more than once. An existing bug report already describes this very problem. Even if you feel that your issue is somewhat different, the resolution is likely to be the same. Thank you for your interest in PHP. Previous Comments: ------------------------------------------------------------------------ [2005-11-03 21:10:23] tony at marston-home dot demon dot co dot uk Description: ------------ When I use foreach($array as $key => $value) on an indexed array, afterwards the index value, when viewed with key($array) is null instead of an integer. This means that when my code tests the array to see if it is either indexed or associative it is given the wrong answer. Reproduce code: --------------- <?php $array[] = 'string of data'; if (is_int(key($array))) { echo "array is indexed\n"; } else { echo "array is associativ\/n"; } // if foreach ($array as $key => $value) { if ($key === key($array)) { echo "they are the same\n"; } else { echo "they are NOT the same\n"; } // if } // foreach if (is_int(key($array))) { echo "array is indexed\n"; } else { echo "array is associative\n"; } // if ?> Expected result: ---------------- The output 'array is indexed' should be produced both before and after the foreach() statement. Actual result: -------------- The key of an indexed array, when viewed with key($array), is not being reported as an integer. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=35093&edit=1