Knowledge needs to be consolidated more, especially some very simple little knowledge. sometimes it is easy to forget it if you don't get in touch for a long time. Today, my colleague encountered a small problem when using in_array (). after checking the information, I found that I still did not remember my basic knowledge.
Knowledge needs to be consolidated more, especially some very simple little knowledge. sometimes it is easy to forget it if you don't get in touch for a long time. Today, my colleague encountered a small problem when using in_array (). after checking the information, I found that I still did not remember my basic knowledge...
Yes. when using in_array ($ k, $ arr) to determine whether $ k is in the $ arr array, when $ k = 0, in_array () is found () returns true. $ Arr does not have the value 0 at the beginning. Later, when I checked the information, I noticed that "when comparing and calculating numbers and strings, PHP will forcibly convert the strings into numbers". The reason is here, because the $ arr array contains all some string values, when using in_array () for determination, php will convert the string to a number before judging. if the string is all non-numeric, php converts it to 0. Therefore, it is understandable that a true value is returned after the result is determined ~~
A little bit of knowledge points directly reflect the shortcomings of your own learning. if you do not have a solid foundation, you will be prone to this "disease", and you will be entangled in problems that shouldn't have been tangled up...