title: How to delete duplicate elements in a multidimensional array?
body: <p>I have a json file like this. It contains popular songs by year. I will use this songs to create decade based playlists later.</p>
  
  <pre><code>{
      "1940": [
          {
              "artist": "Tommy Dorsey",
              "title": "I'll Never Smile Again"
          },
          {
              "artist": "Bing Crosby",
              "title": "Only Forever"
          },
          {
              "artist": "Artie Shaw",
              "title": "Frenesi"
          },
          {
              "artist": "Glenn Miller",
              "title": "The Nearness of You"
          },
          {
              "artist": "Artie Shaw",
              "title": "Frenesi"
          },
          {
              "artist": "Tommy Dorsey &amp; Frank Sinatra",
              "title": "Imagination"
          },
          {
              "artist": "Cliff Edwards (Ukelele Ike)",
              "title": "When You Wish Upon a Star"
          },
          {
              "artist": "Bing Crosby",
              "title": "Sierra Sue"
          },
          {
              "artist": "The Ink Spots",
              "title": "Java Jive"
          },
          {
              "artist": "Jimmy Dorsey",
              "title": "6 Lessons From Madame La Zonga"
          },
          {
              "artist": "Jimmie Davis",
              "title": "You Are My Sunshine"
          },
          {
              "artist": "Bob Wills &amp; his Texas Playboys",
              "title": "New San Antonio Rose"
          },
          {
              "artist": "Tommy Dorsey",
              "title": "Stardust"
          },
          {
              "artist": "The Andrews Sisters",
              "title": "Beat Me Daddy, Eight To The Bar"
          },
          {
              "artist": "Charlie Barnet",
              "title": "Pompton Turnpike"
          },
          {
              "artist": "Judy Garland",
              "title": "I'm Nobody's Baby"
          },
          {
              "artist": "Bob Crosby &amp; his Orchestra",
              "title": "Down Argentina Way"
          },
          {
              "artist": "Kate Smith",
              "title": "The Woodpecker Song"
          },
          {
              "artist": "Shep Fields &amp; his Rippling Rhythm Orchestra",
              "title": "Down Argentina Way"
          },
          {
              "artist": "Vaughn Monroe",
              "title": "There I Go"
          },
          {
              "artist": "Will Bradley",
              "title": "There I Go"
          },
          {
              "artist": "Mitchell Ayres &amp; his Fashions in Music",
              "title": "Make Believe Island"
          },
          {
              "artist": "Joe Loss Orchestra",
              "title": "Beer Barrel Polka (Roll out the Barrel)"
          },
          {
              "artist": "Carson Robison",
              "title": "South of the Border (Down Mexico Way)"
          },
          {
              "artist": "Francisco Alves",
              "title": "Dama das Camelias"
          },
          {
              "artist": "Duke Ellington",
              "title": "Ko Ko"
          },
          {
              "artist": "Bill Monroe",
              "title": "Mule Skinner Blues"
          },
          {
              "artist": "Bukka White",
              "title": "Special Stream Line"
          },
          {
              "artist": "Tony Martin",
              "title": "It's a Blue World"
          },
          {
              "artist": "Orlando Silva",
              "title": "Suplica"
          },
          {
              "artist": "Ella Fitzgerald",
              "title": "Five O'Clock Whistle"
          },
          {
              "artist": "Edith Piaf",
              "title": "L'accordeoniste"
          },
          {
              "artist": "Erskine Hawkins",
              "title": "Dolemite"
          },
          {
              "artist": "Dick Robertson &amp; his Orchestra",
              "title": "Ma (He's Making Eyes At Me)"
          },
          {
              "artist": "Kay Kyser",
              "title": "Playmates"
          },
          {
              "artist": "Nat Gonella",
              "title": "I'm Nobody's Baby"
          },
          {
              "artist": "Bando da Lua",
              "title": "O Samba da Minha Terra"
          },
          {
              "artist": "Cyro Monteiro",
              "title": "Oh! Seu Oscar"
          },
          {
              "artist": "Roland Hayes",
              "title": "Were You There?"
          },
          {
              "artist": "Benny Goodman",
              "title": "Seven Come Eleven"
          },
          {
              "artist": "Sammy Kaye",
              "title": "Dream Valley"
          },
          {
              "artist": "Bob Chester &amp; his Orchestra",
              "title": "Practice Makes Perfect"
          },
          {
              "artist": "Frank Proffitt",
              "title": "Tom Dooley"
          },
          {
              "artist": "Art Tatum",
              "title": "Sweet Lorraine"
          },
          {
              "artist": "Dircinha Batista",
              "title": "Upa! Upa! (Meu Trolinho)"
          },
          {
              "artist": "Connee Boswell",
              "title": "On the Isle of May"
          },
          {
              "artist": "Aracy de Almeida",
              "title": "Passarinho do Relogio (Cuco)"
          }
      ],
      "1941": [
          {
              "artist": "Glenn Miller",
              "title": "Chattanooga Choo Choo"
          },
          {
              "artist": "Artie Shaw",
              "title": "Frenesi"
          },
          {
              "artist": "Jimmy Dorsey",
              "title": "Blue Champagne"
          },
          {
              "artist": "Sammy Kaye",
              "title": "Daddy"
          },
          {
              "artist": "Freddy Martin",
              "title": "Piano Concerto in B Flat"
          },
          {
              "artist": "Glenn Miller",
              "title": "Adios"
          },
          {
              "artist": "Sammy Kaye",
              "title": "Daddy"
          },
          {
              "artist": "Artie Shaw",
              "title": "Blues in the Night"
          },
          {
              "artist": "Billie Holiday",
              "title": "God Bless the Child"
          },
          {
              "artist": "Jimmy Dorsey",
              "title": "Jim"
          },
          {
              "artist": "The Andrews Sisters",
              "title": "I'll Be With You in Apple Blossom Time"
          },
          {
              "artist": "Duke Ellington",
              "title": "I Got it Bad &amp; That Ain't Good"
          },
          {
              "artist": "Horace Heidt",
              "title": "G'bye Now"
          },
          {
              "artist": "Freddy Martin",
              "title": "The Hut Sut Song (A Swedish Serenade)"
          },
          {
              "artist": "The Ink Spots",
              "title": "I Don't Want to Set the World On Fire"
          },
          {
              "artist": "Harry James",
              "title": "Music Makers"
          },
          {
              "artist": "Tommy Dorsey &amp; Frank Sinatra",
              "title": "This Love of Mine"
          },
          {
              "artist": "The Sons of the Pioneers",
              "title": "Cool Water"
          },
          {
              "artist": "Benny Goodman",
              "title": "Solo Flight"
          },
          {
              "artist": "Xavier Cugat",
              "title": "Chica, Chica, Boom, Chic"
          },
          {
              "artist": "Ernest Tubb",
              "title": "Walking the Floor Over You"
          },
          {
              "artist": "Guy Lombardo",
              "title": "And the Band Played On"
          },
          {
              "artist": "Vera Lynn",
              "title": "A Nightingale Sang in Berkeley Square"
          },
          {
              "artist": "Dick Robertson",
              "title": "Ferryboat Serenade"
          },
          {
              "artist": "The Jesters",
              "title": "It's a Great Day for the Irish"
          },
          {
              "artist": "The Tic-Toc Rhythm Orchestra",
              "title": "Ferryboat Serenade"
          },
          {
              "artist": "Judy Garland",
              "title": "It's a Great Day for the Irish"
          },
          {
              "artist": "Francisco Alves",
              "title": "Canta Brasil"
          },
          {
              "artist": "George Formby",
              "title": "Bless 'em All (The Service Song)"
          },
          {
              "artist": "Al Bowlly",
              "title": "When That Man is Dead &amp; Gone"
          },
          {
              "artist": "Bing Crosby",
              "title": "Shepherd's Serenade"
          },
          {
              "artist": "Tommy Dorsey",
              "title": "Do I Worry?"
          },
          {
              "artist": "Charlie Barnet",
              "title": "I Hear A Rhapsody"
          },
          {
              "artist": "Wayne King",
              "title": "You Are My Sunshine"
          },
          {
              "artist": "Gene Krupa",
              "title": "It All Comes Back To Me Now"
          },
          {
              "artist": "Big Maceo Merriweather",
              "title": "Worried Life Blues"
          },
          {
              "artist": "Big Bill Broonzy",
              "title": "Key to the Highway"
          },
          {
              "artist": "Joe Loss Orchestra",
              "title": "'V' Stands For Victory"
          },
          {
              "artist": "Carlos Galhardo",
              "title": "Ala Li La"
          },
          {
              "artist": "Tommy Tucker",
              "title": "I Don't Want to Set the World On Fire"
          },
          {
              "artist": "Kay Kyser",
              "title": "Alexander the Swoose (Half Swan, Half Goose)"
          },
          {
              "artist": "Al Donahue",
              "title": "The Wise Old Owl"
          },
          {
              "artist": "Woody Herman",
              "title": "Blue Flame"
          },
          {
              "artist": "Washboard Sam",
              "title": "She Belongs to The Devil"
          },
          {
              "artist": "Dorival Caymmi",
              "title": "O Mar"
          },
          {
              "artist": "Ray Noble",
              "title": "By the Light of the Silvery Moon"
          },
          {
              "artist": "Joel &amp; Gaucho",
              "title": "Aurora"
          },
          {
              "artist": "Jay McShann",
              "title": "Vine Street Blues"
          }
      ]
  }
  </code></pre>
  
  <p>I am trying to delete duplicate entries in each year. I tried but It does not work:</p>
  
  <pre><code>&lt;?php
  
      $decade = file_get_contents("decade.json");
      $decade = json_decode($decade, true);
  
      foreach($decade as $key =&gt; $year) {
          foreach($year as $k =&gt; $item) {
              $title  = $item["title"];
              $artist = $item["artist"];
              $i = 0;
              foreach($year as $kkk =&gt; $it) {
                  if ($it["title"] = $title) {
                      unset($decade[$key][$kkk]);
                      //echo "found";
                  }
                  $i = $i + 1;
              }
          }
      }
  
      echo json_encode($decade);
  ?&gt;
  </code></pre>