Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Jul 2007
    Posts
    65
    Thanks
    2
    Thanked 0 Times in 0 Posts

    checking for multiple entries in exploded array

    Hi
    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 ;-)

  • #2
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,039
    Thanks
    19
    Thanked 42 Times in 42 Posts
    use in_array() to see if the value is in the array if it isnt add it if it is dont
    source:
    www.php.net/in_array

  • #3
    New Coder
    Join Date
    Jul 2007
    Posts
    65
    Thanks
    2
    Thanked 0 Times in 0 Posts
    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.
    i.e.
    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.
    Cheers

  • #4
    New Coder
    Join Date
    Jul 2007
    Posts
    24
    Thanks
    1
    Thanked 0 Times in 0 Posts
    You could use array_count_values()

    http://au2.php.net/manual/en/functio...unt-values.php

  • #5
    New Coder
    Join Date
    Jul 2007
    Posts
    65
    Thanks
    2
    Thanked 0 Times in 0 Posts
    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 ;-)

  • #6
    New Coder
    Join Date
    Jul 2007
    Posts
    65
    Thanks
    2
    Thanked 0 Times in 0 Posts
    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..

    Cheers


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •