php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #20645 function array_search return zero instead of false!
Submitted: 2002-11-26 07:56 UTC Modified: 2002-11-26 11:25 UTC
From: hzerres at aol dot com Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 4.2.2 OS: win2k
Private report: No CVE-ID: None
 [2002-11-26 07:56 UTC] hzerres at aol dot com
I try to find some entry in an Array beginning with 
index 0. I test for false to treat the "not found" event
but don?t find my entrys in the first line.
If i test for 0 i always end up with my fist line.

$this->wochentage_name=array(
		array(0,"Monday","Montag","Mo"),
		array(1,"Tuesday","Dienstag","Di"),
		array(2,"Wednesday","Mittwoch","Mi"),
		array(3,"Thursday","Donnerstag","Do"),
		array(4,"Friday","Freitag","Fr"),
		array(5,"Saturday","Samstag","Sa"),
		array(6,"Sunday","Sonntag","So")
		);

for($i=0;$i<sizeof($this->wochentage_name);$i++)
{
	print_r($this->wochentage_name[$i]);
	echo "ENDE f?r Nummer".$i."<br>";
	$key = array_search($in,$this->wochentage_name[$i]);
 	if($key != 0)
		{
		return $this->wochentage_name[$i][$row];
		}
}


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-11-26 11:25 UTC] moriyoshi@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

You have to use "!==" operator when you want to distinguish 0 and false.


 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sun Jan 26 09:01:24 2020 UTC