Jump to content

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


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

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.