I basically just want to pull out one random testimonial from a flat text file that I have. I have the code to pull them in, shuffle them, and display them ALL using a foreach statement…. but I am not sure what to do if I want just ONE. Should I change up the foreeach?
srand((double)microtime()*1000000);
$f_contents = file_get_contents("testimonials.txt");
$line = explode("\n",$f_contents);
$noe = count($line);
shuffle($line);
foreach ($line as $str ){
//echo code to output
}
Thank you in advance for the help! 🙂
once shuffled just use the first one in the array
array_rand() and not shuffling is probably faster