Is there a way to select a random part of an array> like a echo $array[random] ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Is there a way to select a random part of an array> like a echo $array[random] ?

7th Apr 2017, 5:49 AM
Connor Snell
Connor Snell - avatar
2 Answers
+ 3
I don't think there's any direct way for that. So, generate two random numbers in the range of array index. Take the substring between them.
7th Apr 2017, 2:01 PM
Krishna Teja Yeluripati
Krishna Teja Yeluripati - avatar
+ 2
You almost anwered your question by yourself... read it again you are very close ^^"
7th Apr 2017, 6:10 AM
Geoffrey L
Geoffrey L - avatar