WhiteRau Posted September 29, 2011 Share Posted September 29, 2011 hello! in my header.php file i have the following line of code: <link rel="stylesheet" href="<?php echo $pageCSS; ?>"> in the document proper, i have the following at the top of the page: <?php $pageCSS="_css/compare.css"; ?> this works as expected and it's clean and neat. what i want to know is how i can adapt this to pass MULTIPLE JavaScript files through it. would it be best to pass an array of files and then step through the array? would be nice to be able to pass a simple comma-delimited list. any help would be appreciated. WR! Quote Link to comment https://forums.phpfreaks.com/topic/248143-how-can-i-load-multiple-cssjavascript-files-in-php/ Share on other sites More sharing options...
btherl Posted September 29, 2011 Share Posted September 29, 2011 There are many possibilities, one of which is: Defining the CSS files: <?php $css_files = array( "_css/compare.css", "_css/groovy.css", ); ?> And then when you are producing the HTML output: <?php foreach ($css_files as $cf) { print "<link rel=\"stylesheet\" href=\"$cf\">\n"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/248143-how-can-i-load-multiple-cssjavascript-files-in-php/#findComment-1274226 Share on other sites More sharing options...
WhiteRau Posted September 30, 2011 Author Share Posted September 30, 2011 @btherl: brilliant. thank you. i suspected it would be something along those lines, but i wanted to be sure. this headcold is making me stupid... thank you so much. WR! Quote Link to comment https://forums.phpfreaks.com/topic/248143-how-can-i-load-multiple-cssjavascript-files-in-php/#findComment-1274232 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.