Edit report at https://bugs.php.net/bug.php?id=63226&edit=1
ID: 63226 Updated by: ni...@php.net Reported by: nicholas dot puleo at gmail dot com Summary: Mixed array index iteration has broken key=>value pair -Status: Open +Status: Not a bug Type: Bug Package: Arrays related Operating System: Ubuntu 12.0.4.1 LTS PHP Version: 5.4.7 Block user comment: N Private report: N New Comment: 0 == "text", that's why you see it twice. If you want a strict string check use $k === "text". Previous Comments: ------------------------------------------------------------------------ [2012-10-05 16:47:57] nicholas dot puleo at gmail dot com Description: ------------ If getting an array with mixed index types (in this case it was served from LDAP) - iterating over using a foreach loop yielded incorrect key values on the first changed index from associative to numerical. Test script: --------------- <?php $d = array(); $d['text'] = 1; $d[0] = 1; $d[1] = 2; foreach ($d as $k=>$v) { if ($k == "text") { echo 'Should Only See Once'; } else { echo $v; } } ?> ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=63226&edit=1