Ok I have an array thats created in a loop session:

$countuid[] += $uid;

I want to ask if the array key $uid matches more than once in the array .......'do something'

I cant work it out Ive been looking at 'array_key_exists' but cant seem to find the right syntax for the if statement.

My array is coming out as: Array ( [0] => 54 [1] => 54 [2] => 54 [3] => 55 [4] => 55 )
But as I said its in a session so that will change.

    You are not really setting any keys, if you want to do something on a value existing in the array, use array_search().

      Depending on what it is you are trying to accomplish, you could use [man]array_filter[/man] after the fact to eliminate duplicate values in the array.

        Instead of this (which does not seem to make sense in any case):
        $countuid[] += $uid;

        use this:
        $countuid[$uid] = $uid;

        then you can use
        if(array_key_exists($uid, $countuid)
        {
        // do something
        }

          Thank you very much thats much appreciated!!
          I spent far to long on that yesturday, I knew it was something fairly simple!
          I tried something very close to that but couldn't work it out.
          That was nearly the last of my pig of a shipping cost script!

          Thanks thats just great!

            Remember to mark this thread as resolved using the thread tools.

              Write a Reply...