Hi frnds,

I need to seperate keys based on valuee.

Please check the below array.

Array ( [0] => 10:00 to 10:15, 10:30 to 11:00, 
        [1] => 10:00 to 10:15, 10:30 to 11:00,
        [2] => 10:30 to 12:15, 
        [3] =>
        [4] => 10:00 to 10:15, 10:30 to 11:00,
        [5] => 
        [6] => 10:30 to 12:15, ) 

i want to get the keys based on the duplicate values and distinct values like below.

0,1,4


and 

2,3,5,6

Please suggest me......

Thanks in Advance...

Recommended Answers

All 3 Replies

in php , i think use

array_unique() method which returns unique entries of the given array

and then you will get the index values of those unique entries by using array_keys()
method and finally you have to display the remaining indexes for your second requirement

check it once and let me know if you have any confusion in my solution

Member Avatar for diafol

Duplicates: 0,1,4 and 3,5 and 2,6
Uniques: 0,2,3

I'm a little confused at to what you're trying to get.

This should be done while you are filling the array not afterward, that is unless the array is auto populated through some data reading process. While you are filling the array you should be searching it for duplicate values while populating two other arrays for duped and nonduped keys. As you fill the array you enter the key into the nonduped array and once you find a dup you will need to pull the duped keys out of the nonduped array and insert them into the duped array. This should leave the nonduped array with nonduped keys and the duped array with duped keys. I can't think of any easier way to do it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.