Let's talk about whether the PHP checks whether a value of in_array function exists in the array. let's talk about the in_array_PHP tutorial.

Source: Internet
Author: User
Let's talk about whether the PHP checks whether there is a value in_array function in the array, and talk about in_array. Let's talk about whether a value in_array function exists in the PHP check array, and talk about whether a value exists in the in_arrayPHPin_array () function check array. If yes, return TRUE, otherwise, we will discuss whether the PHP checks whether a value of in_array function exists in the array and the in_array function.

The PHP in_array () function checks whether a value exists in the array. If yes, TRUE is returned; otherwise, FALSE is returned.

Syntax:

bool in_array( mixed needle, array array [, bool strict] )

Parameter description:

Parameters Description
Needle The value to be searched in the array. if it is a string, it is case sensitive.
Array Array to be retrieved
Strict Optional. If this parameter is set to TRUE, the needle and array value types are checked.

Example:

<? Php $ arr_a = array ("a", "B", "c", 1); if (in_array ("a", $ arr_a )) {echo 'character a exists in the $ arr_a array';} else {echo 'character a does not exist in the $ arr_a array';}?>

The output result is as follows:

For example, if character a is strictly checked in the $ arr_a array:

<? Php $ arr_a = array ("a", "B", "c", 1); if (in_array ("1", $ arr_a, TRUE )) {echo 'character 1 exists in the $ arr_a array';} else {echo 'character 1 does not exist in the $ arr_a array';}?>

The output result is as follows:

Character 1 does not exist in the $ arr_a array as a needle example:

<? Php $ arr_a = array ("a", "B"), 1, 2); $ arr_ B = array ("a", "B "); if (in_array ($ arr_ B, $ arr_a) {echo 'array $ arr_ B exists in $ arr_a array ';} else {echo 'array $ arr_ B does not exist in $ arr_a array';}?>

The output result is as follows:

Array $ arr_ B exists in the $ arr_a array

The above discussion about whether the in_array function exists in the PHP check array is all the content shared by the editor. I hope you can provide a reference and support for the help house.

The in_array function checks whether a value exists in the array by using the in_array PHP in_array () function. If yes, return TRUE; otherwise, return...

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.