#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Posts
    2
    Rep Power
    0
    Maybe this is a stupid question, but is it possible to randomly change the title of a page with PHP?

    Please don't reply with saying it's a stupid question a hundred times, it's not apropiate
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jul 2000
    Posts
    669
    Rep Power
    15
    Sure you could set the title as a variable like:
    <title><?php print $randtitle; ?></title>

    To get $randtitle create a text file with a different title on each line. Or store them in a database

    With textfile solution:
    //Read textfile into an array each line a new eleemnt
    $file = file("/www/yourtextfile");
    //Seeds the random function
    srand((double)microtime()*1000000);
    //Picks a random number between 0 and the number of titles
    $randval = rand (0,(count($file)-1));
    //Assigns the random title to variable $randtitle
    $randtitle = $file[$randval];

    You could do this from your db using the same logic, just changing a few things around, I beleive MySQL even has a rand function to choose a random row for your table!

    Good Luck

    }//end display random image function


  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Posts
    2
    Rep Power
    0
    Thanks!!!!

Similar Threads

  1. Replies: 11
    Last Post: February 21st, 2004, 07:48 AM
  2. Replies: 4
    Last Post: February 13th, 2004, 04:31 PM
  3. Replies: 0
    Last Post: February 8th, 2004, 11:11 PM
  4. Replies: 2
    Last Post: February 5th, 2004, 12:10 AM
  5. pull title from page
    By dukegamma in forum PHP Development
    Replies: 5
    Last Post: January 27th, 2004, 04:45 AM

IMN logo majestic logo threadwatch logo seochat tools logo