Answers for "get random entry from array php"

PHP
4

choose a random word from an array php

$items = array(1, 2, 3, 4, 5);
echo $items[array_rand($items)];
Posted by: Guest on June-27-2020
2

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 "get random entry from array php"

Browse Popular Code Answers by Language