TeamPhotoshop
Reviews, updates and in depth guides to your favourite mobile games - AppGamer.com
Forum Home Latest Posts Search Help Subscribe

php content generator help

Page: 1 Reply
Sep 22nd 2004#160449 Report
Member since: Sep 7th 2002
Posts: 928
Hey guys so I'm working on a site that need a section that randomly loads a differnt section into a table box, the only solutions I could find were for asp which my site is not hosted on windows.

here is the asp version, pretty much its a script that randomly loads a include from an array



<%

'For browsers (set expiration date some time well in the past)
Response.Expires = -1000

'For HTTP/1.1 based proxy servers
Response.CacheControl = "no-cache"

'For HTTP/1.0 based proxy servers
Response.AddHeader "Pragma", "no-cache"

Function RandomNumber(intHighestNumber)
Randomize
RandomNumber = Int(Rnd * intHighestNumber) + 1
End Function

dim RandomContentSelector
RandomContentSelector = RandomNumber(4)

Select Case RandomContentSelector
Case 1
%> <%
Case 2
%> <%
Case 3
%> <%
Case 4
%> <%
End Select

%>


anyone know how to php this or do this in php?

thanks in advance,
-Michael
Reply with Quote Reply
Sep 22nd 2004#160491 Report
Member since: Apr 20th 2002
Posts: 3000
Just pop this where you want the section to be.

[PHP]
/* Each string you enter are paths to the files that contain the section */
$array = array("path/to/file1.ext", "path/to/file2.ext", "path/to/file3.ext");
$randint = rand(0, count($array)-1);

echo $array[$randint];

?>[/PHP]
Reply with Quote Reply
Page: 1 Back to top
Please login or register above to post in this forum