0

Just to let you guys know I tried a number of examples from Stackoverflow with no luck although this may look like a duplicate it's not.

I need to remove duplicate links from an array that have the same date. Duplicates links that do not have the same date should not be removed. Please have a look at the array. I would really appreciate if someone can help me out I'm stuck on this one.

[0] => Array(
         [link] => Array
            (
                [S] => /link1.php
            )
         [date] => Array
            (
                [S] => 06/15/2019
            )
)
[1] => Array(
         [link] => Array
            (
                [S] => /link1.php
            )
         [date] => Array
            (
                [S] => 06/14/2019
            )
)
[2] => Array(
         [link] => Array
            (
                [S] => /link1.php
            )
         [date] => Array
            (
                [S] => 06/15/2019
            )
)
[3] => Array(
         [link] => Array
            (
                [S] => /link2.php
            )
         [date] => Array
            (
                [S] => 06/15/2019
            )
)
Logical Nonsense
  • 393
  • 4
  • 17
  • So, [this solution](https://stackoverflow.com/a/946300/3986005) does not work? – KIKO Software Jun 15 '19 at 08:35
  • Perhaps not the shortest and simplest solution, but you could create a new empty array and then loop through your array that contains the duplicates. String-Concatenate the values in your link and date field and use that value as a key in your new array where you store the current element. Identical elements will give the same key and thus you overwrite the previous duplication. In the end this leaves you without any duplication. If you do not want to keep the string-keys in your new array, you can call array_values () on it to get normal numeric keys. – Dennis Jun 15 '19 at 09:42
  • @u_mulder I don't understand why you marked this as a duplicate did you not read my post? I tried that example before I posted. I clearly mention this is not a duplicate in my post. Lately the quality of SO is decreasing due to people like you. – Logical Nonsense Jun 16 '19 at 06:04
  • @LogicalNonsense here's a code for you __taken from the dupe question__ https://3v4l.org/SYYuv (you could do it yourself but instead you prefer to complain how unfair the world is). – u_mulder Jun 16 '19 at 18:23
  • @u_mulder I'm not complaining that the world is unfair, I don't know how you came up with that assumption. I'm having some trouble with some code and I figured I would post on SO for some help after searching for a half hour and trying many solutions that didn't work including the code from the so called duplicate. – Logical Nonsense Jun 17 '19 at 02:48

0 Answers0