graham23s Posted September 19, 2014 Share Posted September 19, 2014 <?php // Daniel URL duplicator. // Input links list. $linksList = "links.txt"; // How many times to duplicate the url? $manyTimes = 1000; // Read in the list. for ($x = 0; $x <= $manyTimes; $x++) { $handle = fopen($linksList, "r"); $line = fgets($handle); echo $line; fclose($handle); } ?> Hey Guys, I'm stuck on this simple bit of code lol what I'm trying to do is load in a list of urls: site1.com site2.com site3.com etc For each site that is read, I'm trying to duplicate it X times, above would print to screen the same url 1000 times, then move onto the next print it 1000 times etc until the list is done (or how ever many times I select) I can't think of the best way to do it! any help would be appreciated guys! Graham Link to comment https://forums.phpfreaks.com/topic/291173-duplication-list-values/ Share on other sites More sharing options...
cyberRobot Posted September 19, 2014 Share Posted September 19, 2014 The file could be read into an array with file(): http://php.net/manual/en/function.file.php You could then use a foreach loop to process each entry. In the foreach loop, you could use your for loop to display the current entry a 1000 times. Link to comment https://forums.phpfreaks.com/topic/291173-duplication-list-values/#findComment-1491630 Share on other sites More sharing options...
graham23s Posted September 19, 2014 Author Share Posted September 19, 2014 Ah thanks mate worked perfect G Link to comment https://forums.phpfreaks.com/topic/291173-duplication-list-values/#findComment-1491632 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.