Questions about In_array of digital array

Source: Internet
Author: User
On the problem of digital array In_array

Among PHP
$a array contains numbers from 1 to 100

if (In_array (1, $a) {
..........
}

This will put 11, 21. Wait, the 1 of the judges come in.

This is still not working.
In_array (1, $a, TRUE)


How to separate the 1 and 11 in the in array
------to solve the idea----------------------
What's wrong with it?
if (In_array ( 1, Array ( 1, 11,21,31))) {
Echo ' in ';
}
1 in the array, so the output

Reverse to write this
If !In_array (1, Array (11,21,31))) {
echo ' not ';
}

------to solve the idea----------------------
if (In_array (1, $a) {
..........
}

This will put 11, 21. And so on, 1 of all judgment came in.
It's not going to happen.


$a = array (11,12);
Var_dump (In_array (1, $a)); False
?>


Boolean false



$a = array (for each);
Var_dump (In_array (1, $a)); True
?>


Boolean true
  • 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.