php4-beta | 200004
Date: 04/27/00
- Next message: Kevin Hendrix: "Re: [PHP4BETA] Redhat 6.2, PHP4RC1, Oracle 8.1.5?"
- Previous message: Joey: "[PHP4BETA] [REF BUG: 4234] Re: [PHP4BETA] php4 and mysql"
- In reply to: Andreas Pour: "[PHP4BETA] Unique Array Values"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
function distinct_array($ary)
{
if(!is_array($ary)) return 0;
$n = count($ary);
sort($ary);
$i = 1;
$d = 1;
$last = $ary[0];
$dest[0] = $ary[0];
while($i < $n)
{
if($ary[$i] != $last)
$dest[] = $ary[$i];
$last = $ary[$i];
$i++;
}
return $dest;
}
Allen Lee
Assistant Sysadmin
http://MissoulaWeb.com
Hosting, Programming and Design
On Wed, 26 Apr 2000, Andreas Pour wrote:
>
> Hi,
>
> Well, there are many undocumented functions in PHP4 -- maybe the one I'm
> looking for is lurking somewhere. I would like to retrieve all the
> unique values in an array. For example,
>
> array_values(array("cat", "dog", "mouse", "dog"))
>
> would return
>
> array("cat", "dog", "mouse")
>
> If such a function does not exist, perhaps a flag to the current
> array_values for "unique = true" is possible?
>
> Ciao,
>
> Andreas
>
> --
> PHP 4.0 Beta Mailing List <http://www.php.net/version4/>
> To unsubscribe, e-mail: php4beta-unsubscribe <email protected>
> For additional commands, e-mail: php4beta-help <email protected>
> To contact the list administrators, e-mail: php4beta-admin <email protected>
>
>
-- PHP 4.0 Beta Mailing List <http://www.php.net/version4/> To unsubscribe, e-mail: php4beta-unsubscribe <email protected> For additional commands, e-mail: php4beta-help <email protected> To contact the list administrators, e-mail: php4beta-admin <email protected>
- Next message: Kevin Hendrix: "Re: [PHP4BETA] Redhat 6.2, PHP4RC1, Oracle 8.1.5?"
- Previous message: Joey: "[PHP4BETA] [REF BUG: 4234] Re: [PHP4BETA] php4 and mysql"
- In reply to: Andreas Pour: "[PHP4BETA] Unique Array Values"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

