Jump to content

Recommended Posts


$array = array("12:00", "13:20", "12:00", "15:04", "18:30", "15:04", "19:19", "15:04", "18:30");

1.) The first thing I need to do is identify which elements have duplicate values.

2>.) The second thing I need to do is to determin which of the elements that have dupes, has the "most" duplicates.

so in the above the elements with duplicates are;

12:00
15:04
18:30

the element that has the MOST duplicates is;

15:04

I basically need a way to do that.

Any Ideas?

TIA



Who would have thunk it?

" array_count_values(); " , lol

Thanks anyhow folks
Link to comment
https://forums.phpfreaks.com/topic/10862-deals-with-simple-arrays/
Share on other sites

You can use some advanced array functions

$new_array= array_unique($old_array); # get rid of dups
$new_array2= array_diff_assoc($old_array,$new_array); # get only the dups
$keys_old_array= array_keys($new_array2); # keys of dups in old_array other than the first appeance.
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.