Random Greeting in PHP

I was searching for a php  list of greetings but couldn’t find one so I made my own. Thought this may be helpful to someone else looking for a list. Here is how to show a random greeting in php. Much like the flickr welcome page.

//random array function you can use or write your own
function randomArrayVar($array)
if (!is_array($array)){
return $array;
return $array[array_rand($array)];

//list of grettings as arary

$greeting= array(
             "whatsup"=>"What's up",

//echo greeting
echo (randomArrayVar($greeting));

Hope it’s helpful to someone. If you have an additions please leave them in the comments below.

2 thoughts on “Random Greeting in PHP

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.