RE: [PHP] Getting any possible value inside an array
| From: | Aaron Bennett | Date: | Sun, 08 Jul 2001 06:14:06 +0000 |
| Subject: | RE: [PHP] Getting any possible value inside an array | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-56722@lists.php.net to get a copy of this message | ||
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:michaelc@cullerton.com]
Sent: Saturday, July 07, 2001 11:05 PM
To: Aaron Bennett; php-general@lists.php.net
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 abennett@liquidstudio.com 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