a bit of help :D

PHP coding talk.

Moderator: Moderators

a bit of help :D

Postby Mr-Slowly on Thu Apr 12, 2007 8:14 am

Greetings

i have a script that rondomize the webtitle.
but how can i make it work with time
so it can change after some minutes our or weeks orso

can someone help me out with this

this is the script
Code: Select all
<?php
$title[0] = "Web title 0"; // Title 0
$title[1] = "Web title 1"; // Title 1
$title[2] = "Web title 2"; // Title 2
$title[3] = "Web title 3"; // Title 3
$title[4] = "Web title 4"; // Title 4

// get a random number 
$randomize = rand(0, 4);

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title><?php echo ($title[$randomize]); ?></title>
</head>

<body>
Just a simple PHP tut
</body>
</html>
God Bless You
Mr-Slowly
Registered User
Registered User
 
Posts: 29
Joined: Wed Mar 07, 2007 12:15 pm

Postby Mr-Slowly on Fri Apr 13, 2007 3:20 pm

*BUMP*
no one can help me out whit this ??
God Bless You
Mr-Slowly
Registered User
Registered User
 
Posts: 29
Joined: Wed Mar 07, 2007 12:15 pm

Postby UseLess on Sat Apr 14, 2007 12:07 pm

Greetings,

A starting point....
Code: Select all
<?php

$titles_array = array(
   'Title 0',
   'Title 1',
   'Title 2',
   'Title 3',
   'Title 4'
   );

//
// Mode setting: 0 = just random, 1 = random but based on date
//
$mode = 1;
switch( $mode )
{
   case 0:
      // Just get a random title
      $page_title = $titles_array[mt_rand(0,count($titles_array)-1)];
      break;
   
   case 1:
      // Grab a title based on month
      $month = date('n');
      $array_max = count($titles_array);
      
      $page_title = $titles_array[$month % $array_max];
      break;
}
      
?> 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> 
<title><?php echo $page_title; ?></title> 
</head> 

<body> 
Just a simple PHP tut 
</body> 
</html>
Movie Quote:
It's not the years honey, it's the mileage...

I do not provide any install services for phpBB, Mods or Styles.
Please do not pm me for support/scripting help - you won't get any reply. If you have a question then make a post in the appropriate forum.
User avatar
UseLess
Registered User
Registered User
 
Posts: 6220
Joined: Mon Sep 27, 2004 2:14 am
Location: North East, UK

Postby Mr-Slowly on Sat Apr 14, 2007 9:26 pm

Thanx for the scipt useless

this helps me alot :lol:
God Bless You
Mr-Slowly
Registered User
Registered User
 
Posts: 29
Joined: Wed Mar 07, 2007 12:15 pm


Return to PHP Programming

Who is online

Users browsing this forum: Bing [Bot] and 2 guests

cron