I'm creating a google search engine with the CSE of google. I'm trying to get one random result every time i search for a query. For example: When I search for the word "coffee" the engine returns one result, random from all the "coffee results".
Is there someone who can help me to make the result random?
Thanks!!
/dev/random
as it will contain a random stream.%RANDOM%
environment variable.Math.random();
(see here).mixed array_rand ( array $array [, int $num = 1 ] )
or generate a random number with int rand ( int $min , int $max )
.new Random().nextInt(number_of_results + 1);
Number the results (i.e. store them in an array) and use the random number to pick a result (chosen_result = results_array[random_num];
)
If this doesn't suit your needs you will need to provide more information such as the programming language you're using for this.