Jump to content

Duplication list values


Go to solution Solved by cyberRobot,

Recommended Posts

<?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

  • Solution

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.