Home > Article > Backend Development > Exploring the usage of in_array function in php, phpin_array_PHP tutorial
This article explores the usage of in_array function in PHP in depth. Share it with everyone for your reference. The details are as follows:
Today I suddenly thought that the in_array function in PHP has a strange usage. Let’s take a look at this usage. Friends in need can simply refer to it. The code is as follows:
In PHP, if the first parameter is a number - an unquoted number, and the second array parameter contains a string starting with that number, it does not matter whether the first parameter is the complete second parameter. Elements will return true values. In other words, the in_array function does not match the entire element according to my thinking logic every time, or do I not understand the data type clearly enough?
At the same time, I also found that if the first element of your array is 0, problems will also occur. See the following situation, the code is as follows:
Interested friends can test and run the example described in this article, I believe there will be new gains!
I hope this article will be helpful to everyone’s PHP programming design.