note 75946 added to function.array-search
| From: | frio_ej at yahoo dot com | Date: | Fri, 22 Jun 2007 23:54:38 +0000 |
| Subject: | note 75946 added to function.array-search | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-127895@lists.php.net to get a copy of this message | ||
with haystack of sha1'd values in
a multi-array, i compared the values to search
from it which gave an ambiguous two values
instead of one...
needle: 1b6453892473a467d07372d45eb05abc2031647a
Array
(
[0] => Array
(
[id] => 9
[uri] => 0ade7c2cf97f75d009975f4d720d1fa6c19f4897
)
[1] => Array
(
[id] => 8
[uri] => fe5dbbcea5ce7e2988b8c69bcfdfde8904aabc1f
)
[2] => Array
(
[id] => 7
[uri] => 902ba3cda1883801594b6e1b452790cc53948fda
)
[3] => Array
(
[id] => 6
[uri] => c1dfd96eea8cc2b62785275bca38ac261256e278
)
[4] => Array
(
[id] => 5
[uri] => ac3478d69a3c81fa62e60f5c3696165a4e5e6ac4
)
[5] => Array
(
[id] => 4
[uri] => 1b6453892473a467d07372d45eb05abc2031647a
)
[6] => Array
(
[id] => 3
[uri] => 77de68daecd823babbb58edb1c8e14d7106e83bb
)
[7] => Array
(
[id] => 2
[uri] => da4b9237bacccdf19c0760cab7aec4a8359010b0
)
[8] => Array
(
[id] => 1
[uri] => 356a192b7913b04c54574d18c28d46e6395428ab
)
)
----
using rob at robspages dot net (see note below) search
for multi-array needle....
notice: without strict 3rd parameter....
$search = array_search($al, $temp);
result / return value:
Array
(
)
Array
(
)
Array
(
)
Array
(
)
Array
(
)
Array
(
[0] => uri
)
uriArray
(
)
Array
(
)
Array
(
[0] => id
)
id>>9
therefore: return value is incorrect
---
notice: with strict 'true' strict parameter....
$search = array_search($al, $temp, true);
result / return value:
Array
(
)
Array
(
)
Array
(
)
Array
(
)
Array
(
)
Array
(
[0] => uri
)
uriArray
(
)
Array
(
)
Array
(
[0] => id
)
>>6
therefore: return value correct!
----
Server IP: 69.147.83.197
Probable Submitter: 203.177.220.57
----
Manual Page -- http://www.php.net/manual/en/function.array-search.php
Edit -- https://master.php.net/note/edit/75946
Del: integrated -- https://master.php.net/note/delete/75946/integrated
Del: useless -- https://master.php.net/note/delete/75946/useless
Del: bad code -- https://master.php.net/note/delete/75946/bad+code
Del: spam -- https://master.php.net/note/delete/75946/spam
Del: non-english -- https://master.php.net/note/delete/75946/non-english
Del: in docs -- https://master.php.net/note/delete/75946/in+docs
Del: other reasons-- https://master.php.net/note/delete/75946
Reject -- https://master.php.net/note/reject/75946
Search -- https://master.php.net/manage/user-notes.php