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 !! 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); } 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... 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
Archived
This topic is now archived and is closed to further replies.