Hi guys!

I am reading two csv files into 2 multidimensional arrays (5 named columns for each file - so each element in each array consists of 5 named values).

Afterwards I want two compare whether an element in column 1 (1. Array $test)
is identical with an element in column 1 (2. Array $wert).

If this is the case, different elements of both arrays should be assigned to a new array ($Mxsing).

At the moment a for-loop is comparing each element of array 1 ($i) with each element of array 2 ($e).

This is naturally a performance killer.
I need more than a hint please.

Thx
Daniel



$labels=0;
	for ($e=0; $e < $rowcode; $e++)		
{ 
		if ( $test[0][$i][Variablename] ==$wert[0][$e][Variablename] )            

            { $labels++;
	   $Mxsing[$mxgruppe][label][$labels] = preg_replace ( '/<br>/' ,' ' , $wert[0][$e][Wertelabel]) ;
                    $Mxsing[$mxgruppe][wert][$labels]=$wert[0][$e][Codevalue];
           $Mxsing[$mxgruppe][codemax] = $labels;		
         }

}
    9 days later

    Well you could try sorting the arrays, based on matching criteria first. An article that might be of help is here. Then, you can use a "match or discard" technique to whittle your way down through both arrays at the same time.

    I think it might be faster that way.

      Write a Reply...