does anyone know how to get a random item from a .txt file in php?
Printable View
does anyone know how to get a random item from a .txt file in php?
how is the text file delimited?
And what kind of item do you want to get?
<?
for ($i = 1; $i <= 200; $i++)
{
$textfile ="file.txt";
$items = file("$textfile");
$item = rand(0, sizeof($items)-1);
$numbers[$i] = $items[$item];
}
?>
will this code take 200 RANDOM keywords each time from file.txt? file.txt has over 5000+ words. so what i wanted to do was grab 200 random keywords from that 5000 words each time the page is loaded