How does php determine whether an array exists?

Source: Internet
Author: User
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))
{

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.