How do I select random values from an array in PHP?

7331

New Member
I have an array of objects in PHP. I need to select 8 of them at random. My initial thought was to use \[code\]array_rand(array_flip($my_array), 8)\[/code\] but that doesn't work, because the objects can't act as keys for an array.I know I could use \[code\]shuffle\[/code\], but I'm worried about performance as the array grows in size. Is that the best way, or is there a more efficient way?
 
Back
Top