JREAM Posted March 22, 2009 Share Posted March 22, 2009 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 !! Quote Link to comment https://forums.phpfreaks.com/topic/150542-solved-could-you-help-me-loop-these-4-things-faster-i-dont-dare-mess-it-up/ Share on other sites More sharing options...
JREAM Posted March 22, 2009 Author Share Posted March 22, 2009 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); } Quote Link to comment https://forums.phpfreaks.com/topic/150542-solved-could-you-help-me-loop-these-4-things-faster-i-dont-dare-mess-it-up/#findComment-790716 Share on other sites More sharing options...
Maq Posted March 22, 2009 Share Posted March 22, 2009 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... Quote Link to comment https://forums.phpfreaks.com/topic/150542-solved-could-you-help-me-loop-these-4-things-faster-i-dont-dare-mess-it-up/#findComment-790719 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.