I am new here but have checked previous posts about this and although similiar, not quite enough for what I'm trying to do. I have a CSV file with 40K+ records and retrieve LDAP records of 70K+ records; both stored in multidimensional array variable. The objective is to display all records that DO NOT match. My current solution is taking over 20 minutes to process which is inefficient. I created an outer loop that for each record it checks for a match in the LDAP recordset (inner loop), if found skip to next record and unset the LDAP array index to shrink the array for the next loop. I have also sorted both arrays in ascending order to speed up the process. Ideas, tweaks, help to speed up process?
foreach($csvArray as $csvindex=>$csvalue) {
echo "<br />csvArray record: <strong> ".$counter."</strong><br />
";
if($counter <= 1) {
for ($i = 0, $max=$rs["count"]-1; $i < $max ;$i++) { //loop through ldap array
if($csvalue[0] == $rs[$i]['uid'][0]) { // csv netid & ldap netid
echo "CSV netid: ".$csvalue[0];
echo "<br />matched LDAP array [$i] netid: ".$rs[$i]["uid"][0];
echo "<br />
";
$matched = $i; //$i represents integer offset in array (ie. $rs[21])
break;
}
}
} else {
unset($rs[$matched]); //remove matched items
$newRS = array_values($rs); //re-indexes array
echo "Size of new LDAP array: ".count($newRS);
for ($i=0, $max=count($newRS); $i<$max; $i++) {
if($csvalue[0] == $newRS[$i]['uid'][0]) { // csv netid & ldap netid
echo "<br />CSV netid: ".$csvalue[0];
echo "<br />matched LDAP array [$i] netid: ".$newRS[$i]["uid"][0];
echo "<br />
";
$matched = $i; //$i represents integer offset in array (ie. $rs[21])
break;
}
}
}
$counter++;
}
Example of what the original arrays look like (some info changed for security):
//csvArray
Array (
[0] => Array
(
[0] => ABABABAB
[1] => test.account
[2] => Chad
[3] => Moeller
[4] => chad.moeller@macmillan.com
[5] => 9/10/2013 9:29 AM
)
[1] => Array
(
[0] => D2L1.Test
[1] => w40
[2] => D2L
[3] => Test
[4] =>
[5] => 10/28/2013 4:24 PM
)
//ldap multidimensional array
Array (
[count] => 67
[0] => Array
(
[uid] => Array
(
[count] => 1
[0] => alackey1
)
[0] => uid
[count] => 1
[dn] => uid=alackey1,dc=edu
)
[1] => Array
(
[uid] => Array
(
[count] => 1
[0] => blamb3
)
[0] => uid
[count] => 1
[dn] => uid=blamb3,dc=edu
)