|
-
Dec 5th, 2003, 02:11 PM
#1
Thread Starter
Fanatic Member
Randomness
OK, I hope this is teh right forum.
How can I randomly generate phrases?
Now where would they generate from?
-
Dec 5th, 2003, 09:33 PM
#2
Thread Starter
Fanatic Member
*bump the rump*
-
Dec 5th, 2003, 10:39 PM
#3
Lively Member
you want to create entirely random phrases, or randomly select a phrase?
To Select a phrase:
PHP Code:
<?php
/*
Add this line of code in your page:
<?php include "random_quote.php"; ?>
*/
$quotes[] = "This is a quote";
$quotes[] = "This is another";
$quotes[] = "quote 3";
$quotes[] = "quote 4";
$quotes[] = "quote 5";
$quotes[] = "quote 6";
srand ((double) microtime() * 1000000);
$randomquote = rand(0,count($quotes)-1);
echo "<p>" . $quotes[$randomquote] . "</p>";
?>

-morrowasted
-
Dec 5th, 2003, 10:42 PM
#4
if you're even using PHP to do it.. use the rand() function.
to generate phrases, set the phrases into an array and do this:
PHP Code:
<?
$array = array("phrase1","phrase2","phrase3");
$i = rand(0, (count($array) - 1));
echo $array[$i];
?>
there are a number of ways you can put the phrases into an array, like calling up a MySQL database or even just using a plain text file..
-
Dec 5th, 2003, 10:42 PM
#5
Lively Member
hes is shorter, i stole mine from hotscripts... use his

-morrowasted
-
Dec 5th, 2003, 11:06 PM
#6
Thread Starter
Fanatic Member
The include function doesn't seem to show the random_quote.php on my server.
http://www.sniffum.com/secret.html
and
http://www.sniffum.com/random_quote.php
the random_quote.php should show up at the bottom of secret.html 
the only thing that worked for me was iframe's.
That's my last resort. I have enough iFrame's.
-
Dec 5th, 2003, 11:24 PM
#7
You have to include it on a PHP page.
PHP Code:
include("random_quote.php");
So make your secret.html => secret.php
-
Dec 5th, 2003, 11:40 PM
#8
Thread Starter
Fanatic Member
kick ass avatar , thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|