Hi there, i have a textfile with a list of URLS in, one per line. I need some sort of program to jumble up the URLS in the file (ie jumble up the lines) I want to do this hardcopy, so the jumble URLS's are ready to be read, rather than reading a random line. ie www.google.com www.microsoft.com www.bla.com to www.bla.com www.google.com www.microsoft.com (Obviously with a lot more URLs!) Thanks Jon B
open it in excel - make sure you import it so that each line goes in a new row. add a column of random numbers sort it by the random numbers copy, paste the urls back into the text file. hth
Theoretically, this should work, but in practice you seem to get the same result from shuffle() every time. (It was more compact than this (ie; two lines) but due to differing php function returns, it had to be expanded ) PHP: $chrFile = './urls.txt'; $arrURLs = file($chrFile); shuffle($arrURLs); $resFile = fopen($chrFile, 'w+'); fwrite($resFile, str_replace("\n\n", "", implode("\n", $arrURLs))); fclose($resFile); (I made the assumption that seeing as the last of your threads I answered was a PHP question, that PHP would be an ok language to solve this with)
That's probably because you haven't provided a seed for the random number generator. Edit: Use php's php's srand function
I would instead put a number before the url ex. 1 google.com 2 bittech.net 3 something.com pesudeo code generate random number read until end of file if line = random number then read one more line into a string and that is your random url