I just create a color extractor for my gallery. for every image i have a row in database for colors, this is a part of one of those row in database.
Example of row:
CCCCCC,CCCCFF,99CCCC,333333,9999CC,999999,CCFFFF,000000,000033,669999,666699,333366,003333,336666,666666,FFFFFF,FF9900,333300...
i didn't add all colors in here because is too long.
Now, in photo page i need to show those colors, but not all of them. for example just 20 color. so i wrote this code:
$all_colors = $db->super_query("SELECT color
FROM colors
WHERE photo_id='{$photoid}'
");
$list = explode(',',$all_colors['color'], 20);//Select 20 colors
sort($list); //And sorting colors
foreach ($list as $item){
echo $item."<br>";
}
Now the problem is, this is the result from that code:
000000
000033
003333
330000
333300
333333
333366
336666
663300
666633
666666
666699
669999
996633,FFFFCC,CC9966,CCCC99,663333,FF9933,FFCC66,CC9933,CC6600,666600,996600,003300,999966,FFCC33,CCFFCC,996666,999933,FFCC00,CC9999,FFFF99,FF9999
999999
9999CC
99CCCC
CCCCCC
CCCCFF
CCFFFF
You can see a line with too many colors!
Result must be like this:
000000
000033
003333
330000
333300
333333
333366
336666
663300
666633
666666
666699
669999
996633
999999
9999CC
99CCCC
CCCCCC
CCCCFF
CCFFFF
How i can fix this code?