Php determines whether an array exists in the array: array ([0] & nbsp ;=& gt; a [1] & nbsp ;=& gt; B [2] & nbsp ;=& gt; c [3] & nbsp ;=& gt; d) I want to make a judgment, for example, to determine whether a known string a exists in this array, if so, how does php determine whether it exists in the array?
There is an array:
Array
(
[0] =>
[1] => B
[2] => c
[3] => d
)
I want to make a judgment, such as judging whether a known string a exists in this array, and executing a statement if it exists.
------ Solution --------------------
In_array ()
------ Solution --------------------
Reference:
Reference: in_array ($ a, $ array)
How to write IF statements? yes
If (in_array ($ a, $ array) = true)
{
}
?
In_array returns the bool value.
if(in_array($a, $array)){
}
Alas, I made another mistake !!!
------ Solution --------------------
Reference:
Reference: in_array ($ a, $ array)
How to write IF statements? yes
If (in_array ($ a, $ array) = true)
{
}
?
Your writing method is not the best one.
The test is written as follows:
if(in_array($a, $array))
{
}
The test does not exist. write as follows:
if(!in_array($a, $array))
{
}