Random Name Picker


#1

How do I change it so that instead of printing a number, it prints a random name from the list. This is what I have so far.

$friendsandfam = array();
    array_push($friendsandfam, "Ryker");
    array_push($friendsandfam, "Jamie");
    array_push($friendsandfam, "Steve");
    array_push($friendsandfam, "Hallie");
$nameCount = count($friendsandfam); 
echo $nameCount;
$randCount = rand(1, $nameCount);
$winner_name = strtoupper($randCount);
echo $winner_name;

#2

Keeping in mind zero-indexing,

$winner_name = strtoupper($friendsandfam[$randCount - 1]);

#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.