+ 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.

4th Jun 2018, 4:43 PM
andrebtw
andrebtw - avatar
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
4th Jun 2018, 4:56 PM
Mickel
Mickel - avatar
+ 4
Yes Thank you so much !
4th Jun 2018, 6:34 PM
andrebtw
andrebtw - avatar
+ 4
@Mahdi! No problem ! 😃
6th Jul 2018, 2:19 PM
andrebtw
andrebtw - avatar
+ 1
i'm sorry for decline your challenge. that was a wrong touch on screen
6th Jul 2018, 2:18 PM
Mahdi Salek
Mahdi Salek - avatar
+ 1
thanks 😊😉✌
6th Jul 2018, 2:20 PM
Mahdi Salek
Mahdi Salek - avatar