note 61491 deleted from function.in-array by cmb
| From: | cmb@php.net | Date: | Sun, 15 Sep 2019 13:13:21 +0000 |
| Subject: | note 61491 deleted from function.in-array by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-212202@lists.php.net to get a copy of this message | ||
Note Submitter: kitchin
----
Here's a gotcha, and another reason to always use strict with this function.
$x= array('this');
$test= in_array(0, $x);
var_dump($test); // true
$x= array(0);
$test= in_array('that', $x);
var_dump($test); // true
$x= array('0');
$test= in_array('that', $x);
var_dump($test); // false
It's hard to think of a reason to use this function *without* strict.
This is important for validating user input from a set of allowed values, such as from a
<select> tag.