+ 1

How can i display random words from an xml or txt file using php?

Hello. i have a txt file that contain name on each line. i would like to read that file and make an animation of some names available in that file until displaying the final result (the winner). Condition, the winner cant change once choosed and must be displayed to any visitor once the lottery/sorting has been proceed. any tips or help are highly appreciated. i am using php and i am thinking of using some javascript, but im still learning it

8th Mar 2017, 12:40 AM
Djamel Benabbou
Djamel Benabbou - avatar
3 odpowiedzi
+ 2
read everything into an array. keep a counter of how many there are get a random number % size access that index. hope this helps
10th Mar 2017, 5:14 AM
Michael Szczepanski
Michael Szczepanski - avatar
0
hey. thanks for your answer. i understand the idea, but i dont get the 3rd line "get a random number% size". im , begginer in javascript, coule you help/show me this function please?
10th Mar 2017, 9:12 AM
Djamel Benabbou
Djamel Benabbou - avatar
0
create a random number. there aren't many ways to do this. when you do rn % size. it forces that number to be [0, size-1] which are the indexes of your array.a pure ransom function will return a large number. dont know php well enough to tell u what the generator syntax is. ull have to look it up :/
10th Mar 2017, 2:46 PM
Michael Szczepanski
Michael Szczepanski - avatar