Answers for "random array php 3 values"

PHP
5

php get random element from array

<?php
//array_rand ( array $array [, int $num = 1 ] ) 
$input = array("Neo", "Morpheus", "Trinity", "Cypher", "Tank");
$rand_keys = array_rand($input, 2);
echo $input[$rand_keys[0]] . "\n";
echo $input[$rand_keys[1]] . "\n";
?>
Posted by: Guest on June-20-2020
1

random array php

$array = ["a", "b", "c"];
$random = $array[ Rand(0, count($array)-1) ];

echo $random; // a or b or c
Posted by: Guest on August-17-2021

Browse Popular Code Answers by Language