A:array (4) {["api/index/index"] + = string (3) "226" ["main/index/index"] = + string (3) "227" ["main/index/main"] = > String (3) "228" ["/main/index/test"] + string (3) "229"}b:array (+) {["/main/index/test"] = + int (3) ["/main /index/liebiao/text/%e5%88%97%e8%a1%a8%e6%b5%8b%e8%af%95 "] = + string (7)" 0-sec-0 "["/main/index/test/text/%e7% a8%8e%e6%94%b6%e5%88%86%e6%9e%902 "] = + string (7)" 0-sec-1 "["/main/index/test/text/%e7%a8%8e%e6%94%b6%e5%88%86% e6%9e%903 "] + string (7)" 0-sec-2 "["/main/index/test/text/%e7%a8%8e%e6%94%b6%e6%95%b0%e6%8d%ae1 "] + = string (7 ) "1-sec-0" ["/main/index/test/text/%e7%a8%8e%e6%94%b6%e6%95%b0%e6%8d%ae2"] and string (7) "1-sec-1" ["/main/index/ Test/text/%e7%a8%8e%e6%94%b6%e6%95%b0%e6%8d%ae3 "] = + string (7)" 1-sec-2 "["/main/index/test/text/%e4%bc%81%e4% b8%9a%e7%ae%a1%e7%90%861 "] = + string (7)" 2-sec-0 "["/main/index/test/text/%e4%bc%81%e4%b8%9a%e7%ae%a1%e7%90%862 "] = = string (7)" 2-sec-1 "["/main/index/test/text/%e4%bc%81%e4%b8%9a%e7%ae%a1%e7%90%863 "] = + string (7)" 2-sec-2 "["/MAIN/INDEX/TEST/TEXT/%E7%B3%BB%E7%BB%9F%E8%AE%BE%E7%BD %AE1 "] +-string (7)" 3-sec-0 "["/main/tree/index/text/%e6%a0%91%e7%8a%b6%e7%ae%a1%e7%90%86 "] + = string (7)" 3- Sec-1 "["/main/test/index/text/%e5%88%97%e8%a1%a8%e6%b5%8b%e8%af%95 "] + string (7)" 3-sec-2 "["/ucenter/user/ Index/text/%e7%94%a8%e6%88%b7%e7%ae%a1%e7%90%86 "] = + string (7)" 3-sec-3 "["/system/config/index/text/%e9%85%8d% e7%bd%ae%e7%ae%a1%e7%90%86 "] + = string (7)" 3-sec-4 "["/system/index/index "] + int (4) ["/system/subject/index/ Text/%e5%9f%ba%e7%a1%80%e8%ae%be%e7%bd%ae "] = + string (7)" 4-sec-0 "["/system/industry/index/text/%e5%9f%ba%e7% A1%80%e8%ae%be%e7%bd%ae "] = + string (7)" 4-sec-1 "["/system/area/index/text/%e5%9f%ba%e7%a1%80%e8%ae%be%e7%bd%ae "] = = string (7)" 4-sec-2 "["/system/flatrate/index/text/%e5%9f%ba%e7%a1%80%e8%ae%be%e7%bd%ae "] = + string (7)" 4- Sec-3 "["/system/settlement/index/text/%e5%9f%ba%e7%a1%80%e8%ae%be%e7%bd%aE "] = + string (7)" 4-sec-4 "["/system/split/index/text/%e5%9f%ba%e7%a1%80%e8%ae%be%e7%bd%ae "] + = string (7)" 4- Sec-5 "}
With the above two arrays, it is now necessary to know which of the duplicates are
How to be a repeat
The first case, such as the key for the/main/index/test B array in the A-array permission, is/main/index/test, which can be counted as duplicates.
The second case, such as the key for the Main/index/test B array in the permission of a array, is/MAIN/INDEX/TEST/TEXT/FDSFSDFLJL also counted as duplicate data.
Both of these cases are counted as the change of the B array into the C array to use as the intersection
How do I use less time to find the intersection of these two arrays?
What I can think of is that foreach loops a single single match, but when the rule in a is thousands of hundred, the menu item in B is also a few hundred times, there will be more obvious lag, do not know who has a better way to reduce the number of cycles to save the running time of the method
Reply content:
A:array (4) {["api/index/index"] + = string (3) "226" ["main/index/index"] = + string (3) "227" ["main/index/main"] = > String (3) "228" ["/main/index/test"] + string (3) "229"}b:array (+) {["/main/index/test"] = + int (3) ["/main /index/liebiao/text/%e5%88%97%e8%a1%a8%e6%b5%8b%e8%af%95 "] = + string (7)" 0-sec-0 "["/main/index/test/text/%e7% a8%8e%e6%94%b6%e5%88%86%e6%9e%902 "] = + string (7)" 0-sec-1 "["/main/index/test/text/%e7%a8%8e%e6%94%b6%e5%88%86% e6%9e%903 "] + string (7)" 0-sec-2 "["/main/index/test/text/%e7%a8%8e%e6%94%b6%e6%95%b0%e6%8d%ae1 "] + = string (7 ) "1-sec-0" ["/main/index/test/text/%e7%a8%8e%e6%94%b6%e6%95%b0%e6%8d%ae2"] and string (7) "1-sec-1" ["/main/index/ Test/text/%e7%a8%8e%e6%94%b6%e6%95%b0%e6%8d%ae3 "] = + string (7)" 1-sec-2 "["/main/index/test/text/%e4%bc%81%e4% b8%9a%e7%ae%a1%e7%90%861 "] = + string (7)" 2-sec-0 "["/main/index/test/text/%e4%bc%81%e4%b8%9a%e7%ae%a1%e7%90%862 "] = = string (7)" 2-sec-1 "["/main/index/test/text/%e4%bc%81%e4%b8%9a%e7%ae%a1%e7%90%863 "] = + string (7)" 2-sec-2 "["/MAIN/INDEX/TEST/TEXT/%E7%B3%BB%E7%BB%9F%E8%AE%BE%E7%BD %AE1 "] +-string (7)" 3-sec-0 "["/main/tree/index/text/%e6%a0%91%e7%8a%b6%e7%ae%a1%e7%90%86 "] + = string (7)" 3- Sec-1 "["/main/test/index/text/%e5%88%97%e8%a1%a8%e6%b5%8b%e8%af%95 "] + string (7)" 3-sec-2 "["/ucenter/user/ Index/text/%e7%94%a8%e6%88%b7%e7%ae%a1%e7%90%86 "] = + string (7)" 3-sec-3 "["/system/config/index/text/%e9%85%8d% e7%bd%ae%e7%ae%a1%e7%90%86 "] + = string (7)" 3-sec-4 "["/system/index/index "] + int (4) ["/system/subject/index/ Text/%e5%9f%ba%e7%a1%80%e8%ae%be%e7%bd%ae "] = + string (7)" 4-sec-0 "["/system/industry/index/text/%e5%9f%ba%e7% A1%80%e8%ae%be%e7%bd%ae "] = + string (7)" 4-sec-1 "["/system/area/index/text/%e5%9f%ba%e7%a1%80%e8%ae%be%e7%bd%ae "] = = string (7)" 4-sec-2 "["/system/flatrate/index/text/%e5%9f%ba%e7%a1%80%e8%ae%be%e7%bd%ae "] = + string (7)" 4- Sec-3 "["/system/settlement/index/text/%e5%9f%ba%e7%a1%80%e8%ae%be%e7%bd%aE "] = + string (7)" 4-sec-4 "["/system/split/index/text/%e5%9f%ba%e7%a1%80%e8%ae%be%e7%bd%ae "] + = string (7)" 4- Sec-5 "}
With the above two arrays, it is now necessary to know which of the duplicates are
How to be a repeat
The first case, such as the key for the/main/index/test B array in the A-array permission, is/main/index/test, which can be counted as duplicates.
The second case, such as the key for the Main/index/test B array in the permission of a array, is/MAIN/INDEX/TEST/TEXT/FDSFSDFLJL also counted as duplicate data.
Both of these cases are counted as the change of the B array into the C array to use as the intersection
How do I use less time to find the intersection of these two arrays?
What I can think of is that foreach loops a single single match, but when the rule in a is thousands of hundred, the menu item in B is also a few hundred times, there will be more obvious lag, do not know who has a better way to reduce the number of cycles to save the running time of the method
There are official functions that can do this directly ... It's about the way it's written:
array_intersect_uassoc($a, $b, function($ka, $kb) { if( preg_match("%$ka%i", $kb) ) return 0; return $ka - $kb;});