php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #26761 array_search example bug
Submitted: 2004-01-01 17:33 UTC Modified: 2004-01-01 17:35 UTC
From: andrew at netrux dot com Assigned: kennyt (profile)
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
 [2004-01-01 17:33 UTC] andrew at netrux dot com
Description:
------------
<?php
$array = array(0 => "blue", 1 => "red", 2 => "green", 3 => "red");

$key = array_search($array, "green"); // $key = 2;
$key = array_search($array, "red");  // $key = 1;
?> 

The array_search examples arguments are the wrong way around, there searching the needle with the haystack ;)


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-01-01 17:35 UTC] kennyt@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.

I've actually already fixed this. It should show up the 
next time the manual is built. Thanks for the report. 
:)
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Nov 20 14:00:01 2025 UTC