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

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -