javascript - How to create a batch file to add pull info from a txt doc -


currently looking tot speed manual task.

i have several web urls in .txt file i'm hoping add line of code each url.

the code is:

<tr>     <td><a href=""></a></td> </tr> 

basically automate batch file add url in both between commas"" , <> give output file such as:

<tr>     <td><a href="http://www.test1.com/">http://www.test1.com/</a></td> </tr> 

  1. read file.
  2. explode array
  3. loop foreach through array
  4. string replace stub found values.

<?php  $stub  = '<tr><td><a href="%__link__%">%__link__%</a><td></tr>'; $links = [];  $filedata = file_get_contents("filename.txt"); $lines = explode( "\n", $filedata ); // \n unix, \r windows.  foreach( $lines $line ) {     $links[] = str_replace( "%__link__%", $line, $stub ); }  $newfile = join("\n", $links);  file_put_contents("filename.html", $newfile); 

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -