Jump to content

[SOLVED] Could you help me loop these 4 things faster I dont dare mess it up


JREAM

Recommended Posts

Could you help me loop these files faster?

 

The actual code i have now:

$files = "../templates/".$themename."/header.tpl";
$handle = fopen($files, 'w');
fclose($handle);

$files = "../templates/".$themename."/footer.tpl";
$handle = fopen($files, 'w');
fclose($handle);

$files = "../templates/".$themename."/sidebar.tpl";
$handle = fopen($files, 'w');
fclose($handle);

$files = "../templates/".$themename."/style.css";
$handle = fopen($files, 'w');
fclose($handle);

 

I was thinking the file names could be an array like,

$set = array('header.tpl', 'footer.tpl',); // etc..
and something like,


for ($i = 0; $i < count($set); $i++) {
$files = "../templates/".$themename.$set[$i];
$handle = fopen($files, 'w');
fclose($handle);
}

That actually might work but i would like to check so i dont accidently create a ton of files on my ocmputer or crash it !!

 

Got it

	// Make All the Files
	$files = array('header.tpl', 'footer.tpl', 'sidebar.tpl', 'style.css');

	for ($i = 0; $i < count($files); $i++) {
		$make = "../templates/".$theme_name.'/'.$files[$i];
			if ($handle = fopen($make, 'w')) {
				echo $files[$i] . ' Created ';
				}
		fclose($handle);
		}

That actually might work but i would like to check so i dont accidently create a ton of files on my ocmputer or crash it !!

 

Next time, why don't you setup a testing environment so you don't create "a ton" of files on your computer...

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.