Re: Checking for duplicate and make uniqe values in array
| From: | Web Master | Date: | Fri, 08 Dec 2000 11:52:05 +0000 |
| Subject: | Re: Checking for duplicate and make uniqe values in array | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-29324@lists.php.net to get a copy of this message | ||
I am not sure is there any functions available in PHP3 but there is one in PHP4 (per pervious mail).
If you
want to tackle it through program, you can do it using following logic
//idx - index for new array
//newarray - array for unique elements
//ktr - total elements in the old array
//array - old array
idx=0;
ktr=count(array)
for(i=0;i<(ktr -1);i++):
if(array[i] != null):
for(j=(i+1);j<ktr;j++):
if(array[i] == array[j]):
array[j]=null; // may be something else
endif;
endfor;
newarray[idx++]=array[i];
endif;
endfor;
Hope this helps.
vnovakov@ai.sanu.ac.yu wrote:
> If I have an array with some number values:
>
> Can I check for duplicate values, then I need to exclude duplicate and parse the array to uniqe
> values?
>
> Does anyone have any suggestion, advice or example?
>
> Thanks in advance,
> Vladimir
>
> This message sent using EMUmail. http://EmuMail.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net