php - Optimized solution for Comparison in 2D array -


so have 2d array.

array (size=6)   'us-20150018889-a1' =>      array (size=5)       0 => string 'us-13795596' (length=11)       1 => string 'us-13713626' (length=11)       2 => string 'us-11361942' (length=11)       // match 1       3 => string 'wo-ch2003000577' (length=15)       4 => string 'us-20150018889' (length=14)   'us-20140018803-a1' =>      array (size=2)       0 => string 'us-11159064' (length=11)       1 => string 'us-20140018803' (length=14)   'us-8523858-b2' =>      array (size=17)       0 => string 'us-20060287652' (length=14)       1 => string 'cn-101296665' (length=12)       2 => string 'ca-2613278' (length=10)       3 => string 'za-200711136' (length=12)       4 => string 'kr-101334253' (length=12)       5 => string 'jp-5138587' (length=10)       6 => string 'tw-200709800' (length=12)       7 => string 'ep-1893110' (length=10)       8 => string 'in-10213delnp2007' (length=17)       9 => string 'nz-564765' (length=9)       11 => string 'kr-1020080041619' (length=16)       13 => string 'wo-2007001945' (length=13)       14 => string 'tw-i392473' (length=10)       15 => string 'au-2006262507' (length=13)       17 => string 'br-pi0612275' (length=12)       18 => string 'us-8523858' (length=10)       19 => string 'jp-2008546479' (length=13)   'us-8852245-b2' =>      array (size=5)       0 => string 'us-13713626' (length=11)       1 => string 'us-11361942' (length=11)       // match 1       2 => string 'wo-ch0300577' (length=12)      // match 2       3 => string 'us-20130197589' (length=14)       5 => string 'us-8852245' (length=10)   'us-8845698-b2' =>      array (size=4)       0 => string 'us-11361942' (length=11)       // match 1       1 => string 'wo-ch0300577' (length=12)      // match 2       2 => string 'us-20130116735' (length=14)       3 => string 'us-8845698' (length=10)   'us-8343196-b2' =>      array (size=29)       0 => string 'wo-ch03000577' (length=13)       1 => string 'ch-0300577' (length=10)       2 => string 'ep-03818256' (length=11)       3 => string 'wo-2005018472' (length=13)       5 => string 'us-20060235400' (length=14)       6 => string 'au-2003254686' (length=13)       8 => string 'de-50312893' (length=11)       9 => string 'ep-1731107' (length=10)       11 => string 'br-pi0318428' (length=12)       12 => string 'ep-1741397' (length=10)       14 => string 'in-395delnp2006' (length=15)       15 => string 'ca-2536960' (length=10)       16 => string 'jp-2007506450' (length=13)       17 => string 'cn-1819799' (length=10)       18 => string 'ar-045493' (length=9)       19 => string 'tw-i329506' (length=10)       20 => string 'de-20321245' (length=11)       21 => string 'de-20321551' (length=11)       22 => string 'de-20321552' (length=11)       26 => string 'ep-1658015' (length=10)       27 => string 'in-226296' (length=9)       29 => string 'us-8343196' (length=10)       30 => string 'jp-4999327' (length=10)       33 => string 'cl-2004002168' (length=13)       34 => string 'cl-21682004' (length=11)       35 => string 'tw-200514540' (length=12)       36 => string 'de-20321151' (length=11)       37 => string 'de-20321244' (length=11)       38 => string 'nz-545392' (length=9) 

i want compare elements of each index elements of other indexes. , if of elements 1 index matches of elements index, want group 2 indexes together, cannot lose index values either.

i know array_intersect can comparing , grouping can done after that, require 2 loops, (n2 complexity)

is there better way can reduce complexity of logic?

i want see indexes related each other. (relation being common elements)

p/s: provide answers if have more optimized way, because i've implemented via normal logic.
php's inbuilt functions helpful.


Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -