note 75946 rejected from function.array-search by nlopess
| From: | nlopess@php.net | Date: | Sun, 24 Jun 2007 14:41:09 +0000 |
| Subject: | note 75946 rejected from function.array-search by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-127930@lists.php.net to get a copy of this message | ||
Note Submitter: frio_ej at yahoo dot com
----
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!