By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,614 Members | 1,674 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,614 IT Pros & Developers. It's quick & easy.

sort color array?

P: n/a
me
good day,

i found this message:
and i want to know more about it too.
==========================================

Hey all,

example:
$s_Colors="0066FF;0066CC;3366CC;0033FF;003399;0033 66;99CCFF;3399FF;0099FF;66
99CC;336699;006699;66CCFF;33CCFF;00CCFF;3399CC;009 9CC;003333;99CCCC;66CCCC;3
39999;669999;006666;336666;CCFFFF;99FFFF;66FFFF;33 FFFF;00FFFF;00CCCC;99FFCC;
66FFCC;33FFCC;00FFCC;33CCCC;009999;66CC99;33CC99;0 0CC99;339966;009966;006633
;66FF99;33FF99;00FF99;33CC66;00CC66;009933;99FF99; 66FF66;33FF66;00FF66;33993
3;006600;CCFFCC;99CC99;66CC66;669966;336633;003300 ;33FF33;00FF33;00FF00;00CC
00;33CC33;00CC33;66FF00;66FF33;33FF00;33CC00;33990 0;009900;CCFF99;99FF66;66C
C00;66CC33;669933;336600;99FF00;99FF33;99CC66;99CC 00;99CC33;669900;CCFF66;CC
FF00;CCFF33;CCCC99;666633;333300;CCCC66;CCCC33;999 966;999933;999900;666600;F
FFFFF;CCCCCC;999999;666666;333333;000000;43dddd;65 432b;777665;4443cc;CCCCC3;
A906B0;9CC33F;C8C8C8;688888;777752;66E554;7655FF;5 55577;D4DCE8;99AECE;3A5A8A
;9A0030;EF3F6B;FFF543;C906CF;AA2222 ";
And true a function i add random colors in the string,
$s_Colors.= ";".strtoupper($_POST['colorvalue']);

then i make one array:
$a_Colors=array_change_key_case(split(";",$s_Color s), CASE_UPPER);
when i do
sort($a_Colors);
print_r($a_Colors);

or
asort($a_Colors);
print_r($a_Colors);
the values are not correct sorted..!
oke i understand the difference of the hex index so anybody idea??

Cheers,

D
================================================== =
Jul 17 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
me wrote:
good day,

i found this message:
and i want to know more about it too.
==========================================

Hey all,

example:
$s_Colors="0066FF;0066CC;3366CC;0033FF;003399;0033 66;99CCFF;3399FF;0099FF;66
99CC;336699;006699;66CCFF;33CCFF;00CCFF;3399CC;009 9CC;003333;99CCCC;66CCCC;3
39999;669999;006666;336666;CCFFFF;99FFFF;66FFFF;33 FFFF;00FFFF;00CCCC;99FFCC;
66FFCC;33FFCC;00FFCC;33CCCC;009999;66CC99;33CC99;0 0CC99;339966;009966;006633
;66FF99;33FF99;00FF99;33CC66;00CC66;009933;99FF99; 66FF66;33FF66;00FF66;33993
3;006600;CCFFCC;99CC99;66CC66;669966;336633;003300 ;33FF33;00FF33;00FF00;00CC
00;33CC33;00CC33;66FF00;66FF33;33FF00;33CC00;33990 0;009900;CCFF99;99FF66;66C
C00;66CC33;669933;336600;99FF00;99FF33;99CC66;99CC 00;99CC33;669900;CCFF66;CC
FF00;CCFF33;CCCC99;666633;333300;CCCC66;CCCC33;999 966;999933;999900;666600;F
FFFFF;CCCCCC;999999;666666;333333;000000;43dddd;65 432b;777665;4443cc;CCCCC3;
A906B0;9CC33F;C8C8C8;688888;777752;66E554;7655FF;5 55577;D4DCE8;99AECE;3A5A8A
;9A0030;EF3F6B;FFF543;C906CF;AA2222 ";
And true a function i add random colors in the string,
$s_Colors.= ";".strtoupper($_POST['colorvalue']);

then i make one array:
$a_Colors=array_change_key_case(split(";",$s_Color s), CASE_UPPER);
when i do
sort($a_Colors);
print_r($a_Colors);

or
asort($a_Colors);
print_r($a_Colors);
the values are not correct sorted..!
oke i understand the difference of the hex index so anybody idea??

Cheers,

D
================================================== =

What exactly is NOT working? the UPPERCASE function: here is why - from
the manual:

array_change_key_case() changes the keys in the input array to be all
lowercase or uppercase. The change depends on the last optional case
parameter. You can pass two constants there, CASE_UPPER and CASE_LOWER.
The default is CASE_LOWER. **The function will leave number indices as
is.** and a hex value is considered a number.

try:
$a_Colors= explode(";",strtoupper($s_Colors));
sort($a_Colors);
print_r($a_Colors);
Michael Austin.
Jul 17 '05 #2

P: n/a
me
Hey Michael,

Wel as you probaly tested the colors are sorterd in a alpha numeric way but
not in a hex ritme..
I want to have a all the colors that are example in the range of red
together.. and if you make a test and print a table with the colors you see
that they are not sort properly.

Cheers,

M

"Michael Austin" <ma*****@firstdbasource.com> wrote in message
news:gr*****************@newssvr22.news.prodigy.co m...
me wrote:
good day,

i found this message:
and i want to know more about it too.
==========================================

Hey all,

example:
$s_Colors="0066FF;0066CC;3366CC;0033FF;003399;0033 66;99CCFF;3399FF;0099FF;66 99CC;336699;006699;66CCFF;33CCFF;00CCFF;3399CC;009 9CC;003333;99CCCC;66CCCC;3 39999;669999;006666;336666;CCFFFF;99FFFF;66FFFF;33 FFFF;00FFFF;00CCCC;99FFCC; 66FFCC;33FFCC;00FFCC;33CCCC;009999;66CC99;33CC99;0 0CC99;339966;009966;006633 ;66FF99;33FF99;00FF99;33CC66;00CC66;009933;99FF99; 66FF66;33FF66;00FF66;33993 3;006600;CCFFCC;99CC99;66CC66;669966;336633;003300 ;33FF33;00FF33;00FF00;00CC 00;33CC33;00CC33;66FF00;66FF33;33FF00;33CC00;33990 0;009900;CCFF99;99FF66;66C C00;66CC33;669933;336600;99FF00;99FF33;99CC66;99CC 00;99CC33;669900;CCFF66;CC FF00;CCFF33;CCCC99;666633;333300;CCCC66;CCCC33;999 966;999933;999900;666600;F FFFFF;CCCCCC;999999;666666;333333;000000;43dddd;65 432b;777665;4443cc;CCCCC3; A906B0;9CC33F;C8C8C8;688888;777752;66E554;7655FF;5 55577;D4DCE8;99AECE;3A5A8A ;9A0030;EF3F6B;FFF543;C906CF;AA2222 ";
And true a function i add random colors in the string,
$s_Colors.= ";".strtoupper($_POST['colorvalue']);

then i make one array:
$a_Colors=array_change_key_case(split(";",$s_Color s), CASE_UPPER);
when i do
sort($a_Colors);
print_r($a_Colors);

or
asort($a_Colors);
print_r($a_Colors);
the values are not correct sorted..!
oke i understand the difference of the hex index so anybody idea??

Cheers,

D
================================================== =

What exactly is NOT working? the UPPERCASE function: here is why - from
the manual:

array_change_key_case() changes the keys in the input array to be all
lowercase or uppercase. The change depends on the last optional case
parameter. You can pass two constants there, CASE_UPPER and CASE_LOWER.
The default is CASE_LOWER. **The function will leave number indices as
is.** and a hex value is considered a number.

try:
$a_Colors= explode(";",strtoupper($s_Colors));
sort($a_Colors);
print_r($a_Colors);
Michael Austin.

Jul 17 '05 #3

P: n/a
> "Michael Austin" <ma*****@firstdbasource.com> wrote in message
news:gr*****************@newssvr22.news.prodigy.co m...
me wrote:
good day,

i found this message:
and i want to know more about it too.
==========================================

Hey all,

example:

$s_Colors="0066FF;0066CC;3366CC;0033FF;003399;0033 66;99CCFF;3399FF;0099FF;66

99CC;336699;006699;66CCFF;33CCFF;00CCFF;3399CC;009 9CC;003333;99CCCC;66CCCC;3

39999;669999;006666;336666;CCFFFF;99FFFF;66FFFF;33 FFFF;00FFFF;00CCCC;99FFCC;

66FFCC;33FFCC;00FFCC;33CCCC;009999;66CC99;33CC99;0 0CC99;339966;009966;006633

;66FF99;33FF99;00FF99;33CC66;00CC66;009933;99FF99; 66FF66;33FF66;00FF66;33993

3;006600;CCFFCC;99CC99;66CC66;669966;336633;003300 ;33FF33;00FF33;00FF00;00CC

00;33CC33;00CC33;66FF00;66FF33;33FF00;33CC00;33990 0;009900;CCFF99;99FF66;66C

C00;66CC33;669933;336600;99FF00;99FF33;99CC66;99CC 00;99CC33;669900;CCFF66;CC

FF00;CCFF33;CCCC99;666633;333300;CCCC66;CCCC33;999 966;999933;999900;666600;F

FFFFF;CCCCCC;999999;666666;333333;000000;43dddd;65 432b;777665;4443cc;CCCCC3;

A906B0;9CC33F;C8C8C8;688888;777752;66E554;7655FF;5 55577;D4DCE8;99AECE;3A5A8A
;9A0030;EF3F6B;FFF543;C906CF;AA2222 ";
And true a function i add random colors in the string,
$s_Colors.= ";".strtoupper($_POST['colorvalue']);

then i make one array:
$a_Colors=array_change_key_case(split(";",$s_Co lors), CASE_UPPER);
when i do
sort($a_Colors);
print_r($a_Colors);

or
asort($a_Colors);
print_r($a_Colors);
the values are not correct sorted..!
oke i understand the difference of the hex index so anybody idea??

Cheers,

D
=============================================== ====

What exactly is NOT working? the UPPERCASE function: here is why - from
the manual:

array_change_key_case() changes the keys in the input array to be all
lowercase or uppercase. The change depends on the last optional case
parameter. You can pass two constants there, CASE_UPPER and CASE_LOWER.
The default is CASE_LOWER. **The function will leave number indices as
is.** and a hex value is considered a number.

try:
$a_Colors= explode(";",strtoupper($s_Colors));
sort($a_Colors);
print_r($a_Colors);
Michael Austin.


me wrote:
Hey Michael,

Wel as you probaly tested the colors are sorterd in a alpha numeric way but not in a hex ritme..
I want to have a all the colors that are example in the range of red
together.. and if you make a test and print a table with the colors you see that they are not sort properly.

Cheers,

M


[top-post-corrected]

Now that is a horse of a different color. :)

Once you have your array, you will need to break it down into RGB order

FFFFFF
|||||+--> Blue LSByte
||||+---> Blue MSByte
|||+----> Green LSByte
||+-----> Green MSByte
|+------> Red LSByte
+-------> Red MSByte

and sort where Red is predominate etc..., I am guessing you already
figured that one out. In essence you need a 3-dimensional array (not
multiple arrays)... and a way to sort it and still keep the colors intact.

to see how difficult this would be look at a chart I found:
http://www.forestasia.com/tools/colour_chart.asp

After 2.5 hours, I am giving up and going to bed... good night.

Michael Austin.

oh... I guess I should have hit the send button....
Jul 17 '05 #4

P: n/a
Look here for a colorchart::

http://www.xs4all.nl/~sjeef/Nederlands/colorchart.html

Gerard Schaefers
--
Voor meer kook- en eetplezier? Kijk hier!
http://www.xs4all.nl/~sjeef/Nederlands/Recepten.html
Jul 17 '05 #5

P: n/a
me
Thanks but hehe how can i do this in php? :)

I need a color algoritme? that knows wich part is in red and wich part is in
green etc etc??

Cheers,

M
"Sjeef" <sjeef@(WEGHALEN)zeepost.nl> wrote in message
news:40***********************@news.xs4all.nl...
Look here for a colorchart::

http://www.xs4all.nl/~sjeef/Nederlands/colorchart.html

Gerard Schaefers
--
Voor meer kook- en eetplezier? Kijk hier!
http://www.xs4all.nl/~sjeef/Nederlands/Recepten.html

Jul 17 '05 #6

P: n/a
me wrote:
Thanks but hehe how can i do this in php? :)

I need a color algoritme? that knows wich part is in red and wich
part is in green etc etc??

Cheers,

M
"Sjeef" <sjeef@(WEGHALEN)zeepost.nl> wrote in message
news:40***********************@news.xs4all.nl...
Look here for a colorchart::

http://www.xs4all.nl/~sjeef/Nederlands/colorchart.html

Gerard Schaefers
--
Voor meer kook- en eetplezier? Kijk hier!
http://www.xs4all.nl/~sjeef/Nederlands/Recepten.html


Sorry can't help you in this.

Gerard Schaefers
--
Voor meer kook- en eetplezier? Kijk hier!
http://www.xs4all.nl/~sjeef/Nederlands/Recepten.html
Jul 17 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.