I have 10 files containing anywhere from 50 to 250 rows each.
I need to be able to pull 1 or more random rows from different files.
I currently do this...
$lines = file($filePath);
if ($number == "1") {
return $lines[array_rand($lines)];
}
else {
shuffle($lines);
return array_slice($lines, 0, $number);
}
However, I just read of a way to do the same thing using MySQL here:
https://stackoverflow.com/a/4329447/390480
Would I really have that much of a performance gain moving these 10 files to a MySQL database and doing that query instead?
Thanks!