[PHP-BUG] Bug #62165 [NEW]: Array key bug
From: coreyavis at gmail dot com Operating system: Windows 7 PHP version: Irrelevant Package: Unknown/Other Function Bug Type: Bug Bug description:Array key bug Description: --- >From manual page: http://www.php.net/function.array-search --- When using the array_search function to find the key of a value, and then making that key a variable, other functions don't recognize the key 0 (zero) as a valid variable. I have PHP version 5.2.17 but was unable to upgrade cause I host with another company. Test script: --- $array1 = array('value1'); $array2 = array('value1'); for ($x=0; $x<1; $x++) { if (($key = array_search($array2[$x], $array1)) != false) { unset($array1[$key]); } } /* value1 should no longer be in array, but it is. */ print_r($array1); Expected result: $array1 should no longer contain 'value1'. ([0] => ) Actual result: -- $array1 still contains 'value1'. ([0] => 'value1') -- Edit bug report at https://bugs.php.net/bug.php?id=62165&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=62165&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=62165&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=62165&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=62165&r=fixed Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=62165&r=needdocs Fixed in release: https://bugs.php.net/fix.php?id=62165&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=62165&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=62165&r=needscript Try newer version: https://bugs.php.net/fix.php?id=62165&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=62165&r=support Expected behavior: https://bugs.php.net/fix.php?id=62165&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=62165&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=62165&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=62165&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=62165&r=php4 Daylight Savings:https://bugs.php.net/fix.php?id=62165&r=dst IIS Stability: https://bugs.php.net/fix.php?id=62165&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=62165&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=62165&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=62165&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=62165&r=mysqlcfg
Bug #62165 [Opn]: Array key bug
Edit report at https://bugs.php.net/bug.php?id=62165&edit=1 ID: 62165 User updated by:coreyavis at gmail dot com Reported by:coreyavis at gmail dot com Summary:Array key bug Status: Open Type: Bug Package:Unknown/Other Function -Operating System: Windows 7 +Operating System: linux PHP Version:Irrelevant Block user comment: N Private report: N New Comment: I put my home computer operating system, and not the host server operating system. Previous Comments: [2012-05-26 10:14:53] coreyavis at gmail dot com Description: --- >From manual page: http://www.php.net/function.array-search --- When using the array_search function to find the key of a value, and then making that key a variable, other functions don't recognize the key 0 (zero) as a valid variable. I have PHP version 5.2.17 but was unable to upgrade cause I host with another company. Test script: --- $array1 = array('value1'); $array2 = array('value1'); for ($x=0; $x<1; $x++) { if (($key = array_search($array2[$x], $array1)) != false) { unset($array1[$key]); } } /* value1 should no longer be in array, but it is. */ print_r($array1); Expected result: $array1 should no longer contain 'value1'. ([0] => ) Actual result: -- $array1 still contains 'value1'. ([0] => 'value1') -- Edit this bug report at https://bugs.php.net/bug.php?id=62165&edit=1