Randomly pick element in array then remove from the array

后端 未结 5 746
鱼传尺愫
鱼传尺愫 2020-12-30 03:06

I have an array of phrases. I\'d like to randomly pick phrases from the array in a loop. I don\'t want to pick the same phrase more then once in the loop. I thought I could

5条回答
  •  隐瞒了意图╮
    2020-12-30 03:59

    You could also use array_slice

    $ran_Num = array_rand($phrases);
    $ran_Phrase = array_slice($phrases, $ran_Num, 1);
    

提交回复
热议问题