|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2016-12-30 09:05 UTC] 376292871 at qq dot com
Description: ------------ --- From manual page: http://www.php.net/function.array-search --- Test script: --------------- $arr = [241, 248, 249, 250, 255, 256, 257]; $except = [248, 249, 255]; foreach ($except as $value) { if ($key = array_search($value, $arr) !== false) { unset($arr[$key]); } } print_r($arr); exit; Expected result: ---------------- Array ( [0] => 241 [3] => 250 [5] => 256 [6] => 257 ) Actual result: -------------- Array ( [0] => 241 [2] => 249 [3] => 250 [4] => 255 [5] => 256 [6] => 257 ) Patchesarray-search-fix-fix-fix (last revision 2016-12-30 09:12 UTC by 376292871 at qq dot com)Pull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 01 23:00:01 2025 UTC |
your codes seems wrong: if ($key = array_search($value, $arr) !== false) should be: if (($key = array_search($value, $arr)) !== false) {