Loading a random Cascading Styles Sheet

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

nimmØ2
Forum Newbie
Posts: 14
Joined: Thu Feb 08, 2007 3:55 am

Post by nimmØ2 »

Now I'm a bit more confused.

As far as I know, all that information should be in my .css file. Maybe I don't understand how it works.

I'm not familiar with XHTML, just the current version of HTML (four, I assume).

What I'm trying to achieve is for the header to load the .css file into the page.
I'd like to be able to use the 'include' function so I don't have to insert that code into all of my headers.


Thanks for your help.

(and that is what's there right now, as far as the files go)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

array_rand() returns the index of the element it selected, not the element itself. Next, remove the last / from your echo of the <link> tag. And finally, add a <!DOCTYPE> like

Code: Select all

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
nimmØ2
Forum Newbie
Posts: 14
Joined: Thu Feb 08, 2007 3:55 am

Thanks.

Post by nimmØ2 »

Ah, thanks. Would that go in the header? Before it?

hmm.

would this work?

Code: Select all

$cssFiles = array('fileone.css','filetwo.css','filethree.css');
$randomCssFile = $cssFiles[(array_rand($cssFiles))];
echo '<link href="' . $randomCssFile . '" rel="stylesheet" type="text/css" />';
AshrakTheWhite
Forum Commoner
Posts: 69
Joined: Thu Feb 02, 2006 6:47 am

Re: Thanks.

Post by AshrakTheWhite »

it returns the key..

Code: Select all

array
(
    [key] => value
    [key2] => value2
)
nimmØ2
Forum Newbie
Posts: 14
Joined: Thu Feb 08, 2007 3:55 am

Post by nimmØ2 »

Confused.
Post Reply