When I create a master file (client1.php), running this file will create 19 more files, and will search inside the rest and replace the string “client1” for “client2” and so on, and it saves a new file called “client2.php” all the way up to client20.php
Great piece of quick code.
This even create a folder with mkdir
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
<?php $z=2; $today=date("Y-m-d");// todays date $folder = 'inc'.$today; $prefix = 'client'; mkdir($folder, 0755, true); $html = file_get_contents("inc/client1.php"); $handle = fopen($folder.'/'.$prefix.'1.php','w+'); fwrite ($handle,$html); fclose($handle); for ($i = 1; $i < 20; $i++) { $html = str_replace('client'.$i, 'client'.$z, $html); $handle = fopen($folder.'/'.$prefix.$z.'.php','w+'); fwrite ($handle,$html); fclose($handle); echo "\n".$i.$z++; } ?> |