How can I compare two sets of 1000 numbers against each other?

Frurnania

New Member
I must check approximately 1000 numbers against 1000 other numbers.I loaded both and compared them server-side:\[code\]foreach( $numbers1 as $n1 ) { foreach( $numbers2 as $n2 ) { if( $n1 == $n2 ) { doBla(); } }}\[/code\]This took a long time, so I tried to do the same comparison client side using two hidden\[code\]div\[/code\] elements. Then compared them using JavaScript. It still takes 45 seconds to load the page (using hidden \[code\]div\[/code\] elements).I do not need to load the numbers that are not the same.Is there a faster algorithm? I am thinking of comparing them database side and just load the error numbers, then do an Ajax call for the remaining non-error numbers. But is a MySQL database fast enough?
 
Back
Top