php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #20766 array_search doesn't return value with array as needle
Submitted: 2002-12-02 12:41 UTC Modified: 2002-12-02 19:27 UTC
From: francisf at videotron dot ca Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 4.2.3 OS: Linux 2.2.20
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: francisf at videotron dot ca
New email:
PHP Version: OS:

 

 [2002-12-02 12:41 UTC] francisf at videotron dot ca
$t1[] = "banana";
$t1[] = "orange";
$t1[] = "kiwi";

$t2[] = "car";
$t2[] = "kiwi";
$t2[] = "cat";

print "Kiwi key: ".array_search($t1,$t2);

print "Car key: ".array_search("car",$t2);

this code print: Kiwi key: Car key: 0

Should print: Kiwi key: 1 Car key: 0

Apache: 1.3.26 rh 6.2

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-12-02 18:56 UTC] sniper@php.net
It's printing just the correct values.
Your $t2 array does not contain same array as $t1 is..

(try adding this: $t2[] = $t1; and you'll see..)

 [2002-12-02 19:27 UTC] francisf at videotron dot ca
It does work with 
$t1[] = $t2[];

But it's  inneficient.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sat Jan 25 06:01:24 2020 UTC