Usage Analysis of in_array functions in php

Source: Internet
Author: User
This article mainly introduces the in_array function usage in php and analyzes the in_array function usage and related precautions in PHP in the form of examples. It has some reference value. If you need it, you can refer

This article mainly introduces the in_array function usage in php and analyzes the in_array function usage and related precautions in PHP in the form of examples. It has some reference value. If you need it, you can refer

This article analyzes the in_array function usage in php. Share it with you for your reference. The details are as follows:

PHP is a weak language. When using the IN_ARRAY function, try to include the third parameter. The Code is as follows:

The Code is as follows:

Var_dump (in_array (0, array ('s', 'ss'), true); // return false

Var_dump (in_array (0, array ('s', 'ss'); // return true

Var_dump (in_array (0, array (1, 2, 3); // return false


From the above three functions, we can see that when the first one is in_array (0, array ('s', 'ss'), true), the returned value is the value we want.

Usage:

The Code is as follows:

Var_dump (in_array (0, array ('s', 'ss ')));

And:

The Code is as follows:

Var_dump (in_array (0, array (1, 2, 3 )));

The returned ture is obviously not the value we need, because PHP is the weak type, so you should pay attention to it before.

I hope this article will help you with php programming.

,

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.