In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article introduces the knowledge of "how to judge whether two arrays have the same value". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Method: 1, use array_intersect () to compare the values of two arrays, syntax "array_intersect (array 1, array 2)", will return an intersection array; 2, determine whether the intersection array is empty, the syntax "intersection array = = []", if it is empty, there is no same value, if it is not empty, there is the same value.
Operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
Php determines whether two arrays have the same value.
1. Use the array_intersect () function to compare two arrays to get the intersection elements
The array_intersect () function compares the values of two (or more) arrays and returns an intersecting array.
If two arrays have the same value, there are elements in the intersection array, not an empty array
If the two arrays do not have the same value, there are no elements in the intersection array, it is an empty array
2. Determine whether the intersection array is an empty array
If it is an empty array, the two arrays do not have the same value
If it is not an empty array, the two arrays have the same value
The intersection of array 1 and array 2 of echo:
"; $intersect=array_intersect ($arr1,$arr2); var_dump ($intersect); if ($intersect== []) {echo" two arrays do not have the same value
";} else {echo" two arrays have the same value
The intersection of ";} echo" array 2 and array 3:
"; $intersect=array_intersect ($arr3,$arr2); var_dump ($intersect); if ($intersect== []) {echo" two arrays do not have the same value
";} else {echo" two arrays have the same value
";}
That's all for "how php determines whether two arrays have the same value". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.