I am trying to make an array of all the possible colours made out of RGB values. Every permutation between r=0 b=0 g=0 to r=255 b=255 g=255. The idea of my function is that when it's called you supply a limit number so that the function returns an array of RGB values up to this number to stop it returning all 16 million. The code I have below returns 767 permutations (256 * 3) how do I get this to return the full 16 million up to the limit number I provide?
function colourArray($number) {
$r = 0;
$g = 0;
$b = 0;
$i = 0;
while ($i <= $number) {
$colours[] = array($r,$g,$b);
$r++;
$i++;
}
$i = 0;
while ($i <= $number) {
$colours[] = array($r,$g,$b);
$g++;
$i++;
}
$i = 0;
while ($i <= $number) {
$colours[] = array($r,$g,$b);
$b++;
$i++;
}
return $colours;
}