+ 4
PHP Random in an array
Hey everybody ! Can you help me ? I want to output random elements in an array but I don't know how to do that.
5 ответов
+ 4
Something like this?
<?php
$my_array = array('Hello', 'Sololearn', 'Other string');
echo $my_array[array_rand($my_array)];
?>
The array_rand() function returns an index randomly.
http://php.net/manual/en/function.array-rand.php
+ 4
Yes Thank you so much !
+ 4
@Mahdi! No problem ! 😃
+ 1
i'm sorry for decline your challenge.
that was a wrong touch on screen
+ 1
thanks 😊😉✌