Skip to content
Advertisement

Generate array of random unique numbers in PHP

I’m trying to generate an array of random numbers from 0-n then shuffle (but ensure that the keys and values DO NOT match).

For example:

JavaScript

Note that both keys and values are from 0-4 but none of the keys and values are the same.

Any thoughts?

Advertisement

Answer

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement