/    Sign up×
Community /Pin to ProfileBookmark

quick php random

does anyone know how i can do a random sentence from a list made beforehand so i can just get a random sentence by doing a simple putting “$random” in the code will call it.

hope you can help

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@andre4s_yDec 09.2007 — Maybe just put the sentence in the array, then pick the array with rand function, save it in the $random variable, and then echo-ing it.

Something like this :
[code=php]
<?php
$sentence[] = "Good Morning";
$sentence[] = "Good Afternoon";
$sentence[] = "Good Evening";
$random = $sentence[rand(0,count($sentence)-1)];
echo $random;
?>
[/code]

Hope that help you...
Copy linkTweet thisAlerts:
@mitchellauthorDec 10.2007 — thanks so much, mate
×

Success!

Help @mitchell spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...