Menu

#5 bug in ArrayList->contains($element)

open
nobody
5
2004-03-15
2004-03-15
Anonymous
No

Hello,

I found a bug in ArrayList->contains($element).

The original code makes use of array_search
($element,$array), which returns the index of the
element in the array. The issue is that if the element
exists in the array, and it's index is 0, the function will
return FALSE. To correct it I simply changed
array_search() for in_array()

here is the complete code:

arraylist.php

function contains($element)
{
//return (array_search($element,
$this->_elements)) ? TRUE : FALSE;
return (in_array($element, $this-
>_elements)) ? TRUE : FALSE;
}

Regards,

Raul Davidovich
r.davidovich@caconcology.com

Discussion


Log in to post a comment.