A probe into the usage of In_array functions in PHP, Phpin_array
This paper probes into the usage of In_array function in PHP. Share to everyone for your reference. Specific as follows:
Today, suddenly think of PHP In_array function has a strange usage, let's look at this usage, the need for a friend simple reference, the code is as follows:
Copy the code as follows: $a =array ("4");
if (In_array (1, $a)) {
echo "condition established";
}
This condition really is set up, according to my thinking logic on the top of the condition only when the value of parameter 1 is "4" and the time is only established, but it is strange that he actually set up, then test the following situation, the code is as follows:
Copy the Code code as follows: $a =array ("a,2,3", "4");
if (In_array (' a ', $a)) {
echo "condition is not established";
}
This is not true, under the first test case, if the parameter 1 is written as a ' 1 ' condition is also not established, the conclusion is:
In PHP, if the first argument is a number--a number without quotation marks, the second array argument contains a string that starts with that number, whether the first argument is the complete element of the second argument, the true value is returned, that is, in_ Does the array function not always match the entire element according to my thinking logic, or do I know the data type well enough?
At the same time, it is also found that if the first element of your array is 0, there will be a problem, as shown in the following code:
Copy the Code code as follows: $a =array (0, "M");
if (In_array (' mc6 ', $a))
{
echo "=====";
}
Interested friends can test run the example described in this article, I believe there will be a new harvest!
I hope this article is helpful to everyone's PHP programming.
http://www.bkjia.com/PHPjc/917036.html www.bkjia.com true http://www.bkjia.com/PHPjc/917036.html techarticle The usage of in_array function in PHP is explored, Phpin_array this paper explores the usage of In_array function in PHP in depth. Share to everyone for your reference. The following: Suddenly thought of PHP today ...