I have here my php code and txt file. I want to display 6 lines in .txt file randomly at the output of php. How can i do it. I try my code but it only display the first 6 lines. Thanks!
Php:
require_once "config.php";
$txt_file = file_get_contents($database);
$rows = explode("\n", $txt_file);
array_shift($rows);
$i = 0;
foreach($rows as $row => $data)
{
$row_data = explode('&id=', $data);
$info[$row]['name'] = $row_data[0];
$info[$row]['id'] = $row_data[1];
$name = $info[$row]['name'];
$id = $info[$row]['id'];
echo $name."<BR>";
echo $id."<BR><BR>";
if (++$i == "6") break;
}
Txt file:
ABC&id=1
DEF&id=2
GHI&id=3