php - in_array() does not work as expected -
this question has answer here:
for array ($options):
array ( [0] => 0 [1] => 1 [2] => 2 ) php returns true:
$this->asserttrue( in_array('bug', $options ) ); // true $this->asserttrue( in_array('feature', $options ) ); // true $this->asserttrue( in_array('task', $options ) ); // true $this->asserttrue( in_array('rockandroll', $options ) ); // true why?
this because 0 == "string" true, , 0 element of array.
set parameter $strict in in_array true:
$this->asserttrue( in_array('bug', $options, true) );
Comments
Post a Comment