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>
- read file.
- explode array
- loop foreach through array
- 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
Post a Comment