Php searches for the specified content in the array.

Source: Internet
Author: User

$ Array = explode (',', '2014, 2, 1101,110, 418,617,712,713,312,313,104,105,106,107,108 ');
If (in_array ('8', $ array ))
Echo 'A ';
Echo 'B ';

Definition and usage
The in_array () function searches for the given value in the array.

In_array (value, array, type) parameter description
Value is required. Specifies the value to be searched in the array.
Array is required. Specifies the array to be searched.
Type is optional. If this parameter is set to true, check whether the data to be searched is of the same type as the value of the array.

Returns true if the given value exists in the array. If the third parameter is set to true, the function returns true only when the element exists in the array and the data type is the same as the given value.

If no parameter is found in the array, the function returns false.

Note: If the value parameter is a string and the type parameter is set to true, the search area is case sensitive.

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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: and provide relevant evidence. A staff member will contact you within 5 working days.