Bit of an odd request, struggling to get my head round the best way to do this so was looking for some helpful advice if anyone is willing to help out.
Have some php code that writes strings out to a file.
The code which does this is a function that takes in two arguments, these arguments specify the number of strings that should be written to the file.
I want the function to randomly select the strings which it writes to the file but only to write the specified number of strings to the file.
So for example.
The function is called.
randomStrings(4, 3)
in the function i have a list of strings
$s1 = 'ball';
$s2 = 'cat';
$s3 = 'monkey';
$s4 = 'hat';
$s5 = 'somebody at my cakes';
etc
so for the contents of the end file would be something like
hat
monkey
ball
cat
cat
monkey
ball
Anyone any suggestions as to the best way to randomise the strings? So that each time the function is called it randomlly selects the strings to display.
Thanks if you can help.