[BNM] Checking if a bunch of form fields have a duplicate value
Alex
alex at fatdrop.co.uk
Tue Apr 22 15:15:56 BST 2008
something like this should work
$dupe_arr = array();
foreach ($_POST as $value) {
if ( in_array( $value, $dupe_arr) ) {
echo 'dupe found';
} else {
$dupe_arr[] = $value;
}
}
delarge wrote:
> hmmm yes... that could be good, cos if a value is missing that means there
> was a duplicate...
>
> I was thinking more along the lines of...
>
> if(any of them match){write a message}'
>
> but I don't think there's a way to do that
>
>
> On Tue, Apr 22, 2008 at 2:17 PM, Alex Farran <alex at alexfarran.com> wrote:
>
>
>> On Tue, 22 Apr 2008 13:56:28 +0100, delarge <delargerock at gmail.com> said:
>>
>>
>>> hey hey hey... I might be being really thick - but is there a quick way
>>>
>> in
>>
>>> PHP to check if field1, field2, field3, field4 or field5 has a duplicate
>>> value when being processed?
>>>
>> array_unique($array) returns a copy of $array with all the duplicate
>> values removed. You could use that to quickly check for the existence
>> of duplicates, but it won't tell you which elements are duplicates of
>> each other.
>>
>> --
>>
>> Alex Farran Web Development
>> Ruby PHP Javascript MySQL
>> Web: http://www.alexfarran.com
>> Email: alex at alexfarran.com
>> Phone: 01273 474065 / 07790 389330
>> --
>>
>> BNM Subscribe/Unsubscribe:
>> http://www.brightonnewmedia.org/options/bnmlist
>>
>> Archive Search - http://icanhaz.com/bnmarchive
>>
>> BNM powered by Wessex Networks:
>> http://www.wessexnetworks.com
>>
>>
--
http://www.fatdrop.co.uk - digital music services
http://blog.fatdrop.co.uk - music industry blog
The information contained in this message is intended for the addressee only and may contain confidential and/or privileged information. If you are not the addressee, please delete this message and notify the sender. You should not copy or distribute this message or disclose its contents to anyone.
FATDROP LTD | Registered in England and Wales | Company No. 6199983
More information about the BNMlist
mailing list. Powered by Wessex Networks