View Full Version : checking for multiple entries in exploded array

08-22-2007, 03:37 PM
I'm back again after a pc meltdown...... lost rather a lot.... must make more regular backups.

Anyway, thanks to you chaps who helped me a while back, great stuff from all concerned.

Problem is this, trying to use multiple values from an exploded array to update rows.
Currently if there is more than one duplicate value in the array the update only processes the first one, any remaining duplicates of the same value are ignored..

I need to be able to update all values inside the array, duplicates as well.

Any ideas how to make this happen? Maybe if the form could check for multiple entries and handle them differently?

Look forward to hearing back from you.
cheers ;-)

08-22-2007, 03:40 PM
use in_array() to see if the value is in the array if it isnt add it if it is dont

08-22-2007, 04:35 PM
Hi Rafiki
Cool, would I be able to see if there was a duplicate using this?

I am not sure if this is actually what is needed, but its a good place to start.
The issue is that if there are duplicate values in the array only the first one gets updated. I need all duplicates to update if poss.
I don't know what is in the array until it has been exploded from the form post.
imploded ready for update array=(1,2,3,1,4,5,1)
this would result in the db update just updating 1,2,3,4,5 and missing the other 2 1's completely.

08-23-2007, 03:15 AM
You could use array_count_values()


08-23-2007, 09:31 AM
nice one
So now if I find a duplicate entry using array_count_values() what is the best way of resubmitting that item for update ?

Is it possible to extract that particular duplicate into another var and then re run the update just with that var?

cheers ;-)

08-27-2007, 12:55 PM
Can anyone point me in the right direction with this plz?
I am stuck with getting the duplicate value(s) out of the array and being able to use them individually afterwards..