Basically reading a one column file into an array (1000s of lines) and searching a table (3M entries) for matches, then printing out the results in a tab delimited file. It is kinda slow, but it works.
Is there a way to make this faster?
<?php
$db = mysql_connect("$host", "$user", "$password");
mysql_select_db("$dbasename",$db);
$file = "input.txt";
$array1 = array_map('trim',file($file));
$fp = fopen("output.txt", 'w');
foreach($array1 as $id) {
$query = "select new_id from table where old_id like '$id' limit 1";
$results = mysql_query($query);
$result = mysql_fetch_array($results);
$z = $result['new_id'];
fwrite($fp, "$id\t$z\n");
}
fclose($fp);
?>