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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: hzerres at aol dot com
New email:
PHP Version: OS:

 

 [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-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 16 23:01:30 2024 UTC