Answers for "php how to return random array elements"

PHP
8

array random php

<?php
$indexedArray = array("red", "blue", "green", "black");
echo $indexedArray[array_rand($indexedArray)];
?>
Posted by: Guest on September-11-2021
4

php get random value from array

$colors=["red","blue","green","orange"];
echo $colors[array_rand($colors)];//green (or any color randomly)
Posted by: Guest on June-02-2021

Code answers related to "php how to return random array elements"

Browse Popular Code Answers by Language