#39922 [Com]: array_search returns incorrect position after array_push or array_unshift
| From: | smlerman at gmail dot com | Date: | Thu, 21 Dec 2006 13:51:29 +0000 |
| Subject: | #39922 [Com]: array_search returns incorrect position after array_push or array_unshift | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-106735@lists.php.net to get a copy of this message | ||
ID: 39922
Comment by: smlerman at gmail dot com
Reported By: willem at fkkc dot nl
Status: Open
Bug Type: Scripting Engine problem
Operating System: Debian
PHP Version: 5.2.0
New Comment:
Fix your error_reporting and/or display_errors settings.
Warning: Wrong parameter count for array_search() in ... on line 4
http://www.php.net/manual/en/function.array-search.php
Previous Comments:
------------------------------------------------------------------------
[2006-12-21 11:40:41] willem at fkkc dot nl
Description:
------------
array_search returns incorrect position-value when an array is modified
with array_push or array_unshift
Reproduce code:
---------------
$array = array('a1','b2','c3');
array_unshift($array,'d4');
$pos = array_search('d4');
if($pos === FALSE){
print implode(',',$array);
}else{
print 'Position = '.$pos;
}
Expected result:
----------------
Position = 0
Actual result:
--------------
d4,a1,b2,c3
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=39922&edit=1