RE: [PHP] Getting any possible value inside an array

2001-07-09 Thread Adrian Ciutureanu

http://php.net/array_unique

 -Original Message-
 From: Aaron Bennett [mailto:[EMAIL PROTECTED]]
 Sent: 8 iulie 2001 08:52
 To: [EMAIL PROTECTED]
 Subject: [PHP] Getting any possible value inside an array
 
 
 Hi everyone...
 
 Does someone have a quick and dirty way of returning _any_ 
 possible value
 contained within an array?
 
 For instance:
 
 $myarray[0] = red;
 $myarray[1] = red;
 $myarray[2] = red;
 $myarray[3] = blue;
 $myarray[4] = green;
 $myarray[5] = blue;
 $myarray[6] = red;
 
 and i'd output red, blue and green, but not have 
 multiple instances of
 each.
 
 Thanks in advance!
 --
 Aaron Bennett
 

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Getting any possible value inside an array

2001-07-07 Thread Aaron Bennett

Hi everyone...

Does someone have a quick and dirty way of returning _any_ possible value
contained within an array?

For instance:

$myarray[0] = red;
$myarray[1] = red;
$myarray[2] = red;
$myarray[3] = blue;
$myarray[4] = green;
$myarray[5] = blue;
$myarray[6] = red;

and i'd output red, blue and green, but not have multiple instances of
each.

Thanks in advance!
--
Aaron Bennett



Re: [PHP] Getting any possible value inside an array

2001-07-07 Thread mike cullerton

i think this should work

$color_list = array(); // not sure if you need this
foreach ($myarray as $color) {
  if (!in_array($color,$color_list)) $color_list[] = $color;
}

http://php.net/in_array

on 7/7/01 11:51 PM, Aaron  Bennett at [EMAIL PROTECTED] wrote:

 Hi everyone...
 
 Does someone have a quick and dirty way of returning _any_ possible value
 contained within an array?
 
 For instance:
 
 $myarray[0] = red;
 $myarray[1] = red;
 $myarray[2] = red;
 $myarray[3] = blue;
 $myarray[4] = green;
 $myarray[5] = blue;
 $myarray[6] = red;
 
 and i'd output red, blue and green, but not have multiple instances of
 each.
 
 Thanks in advance!
 --
 Aaron Bennett
 


 -- mike cullerton



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] Getting any possible value inside an array

2001-07-07 Thread Aaron Bennett

Perfect! I actually was making up the 'colors' analogy, but i've adapted it
to what i need!
--
Aaron

-Original Message-
From: mike cullerton [mailto:[EMAIL PROTECTED]]
Sent: Saturday, July 07, 2001 11:05 PM
To: Aaron Bennett; [EMAIL PROTECTED]
Subject: Re: [PHP] Getting any possible value inside an array


i think this should work

$color_list = array(); // not sure if you need this
foreach ($myarray as $color) {
  if (!in_array($color,$color_list)) $color_list[] = $color;
}

http://php.net/in_array

on 7/7/01 11:51 PM, Aaron  Bennett at [EMAIL PROTECTED] wrote:

 Hi everyone...
 
 Does someone have a quick and dirty way of returning _any_ possible value
 contained within an array?
 
 For instance:
 
 $myarray[0] = red;
 $myarray[1] = red;
 $myarray[2] = red;
 $myarray[3] = blue;
 $myarray[4] = green;
 $myarray[5] = blue;
 $myarray[6] = red;
 
 and i'd output red, blue and green, but not have multiple instances
of
 each.
 
 Thanks in advance!
 --
 Aaron Bennett
 


 -- mike cullerton




Re: [PHP] Getting any possible value inside an array

2001-07-07 Thread Mark Charette

$newarray=array_flip($myarray)

$newarray will have unique key values made up of the second element of
$myarray.

Mark C.
- Original Message -
From: Aaron Bennett [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Sunday, July 08, 2001 12:51 AM
Subject: [PHP] Getting any possible value inside an array


 Hi everyone...

 Does someone have a quick and dirty way of returning _any_ possible value
 contained within an array?

 For instance:

 $myarray[0] = red;
 $myarray[1] = red;
 $myarray[2] = red;
 $myarray[3] = blue;
 $myarray[4] = green;
 $myarray[5] = blue;
 $myarray[6] = red;

 and i'd output red, blue and green, but not have multiple instances
of
 each.

 Thanks in advance!
 --
 Aaron Bennett



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]