title: Merge values from multiple arrays in PHP
body: <p>I have the following object:</p>
  <pre><code>&quot;themes&quot;: [
      {
        &quot;name&quot;: &quot;Anchor&quot;,
        &quot;categories&quot;: &quot;Creative, Portfolio&quot;,
      },
      {
        &quot;name&quot;: &quot;Agensy&quot;,
        &quot;categories&quot;: &quot;Creative, Portfolio&quot;,
      },
      {
        &quot;name&quot;: &quot;Serenity Pro&quot;,
        &quot;categories&quot;: &quot;One-Page, Multipurpose, Business, Landing Page&quot;,
      },
      {
        &quot;name&quot;: &quot;Integral Pro&quot;,
        &quot;categories&quot;: &quot;One-Page, Multipurpose, Business, Landing Page&quot;,
      }
    ]
  </code></pre>
  <p>I want to iterate through each array and collect the values of the <strong>categories</strong> key</p>
  <p>Then remove duplicates and spit out an array of unique category names.</p>
  <p>I have the following code:</p>
  <pre><code>$json = $this-&gt;curl_get_marketplace_contents();
  $array = json_decode($json, true);
  $categories = array();
  foreach ($array['themes'] as $theme) {
      $array = explode(&quot;,&quot;, $theme['categories']);
      $array = array_map('trim', $array);
      $array = array_values($array);
      $array = array_unique($array);
      $categories = array_push($array, $categories);
      
  };
  return $categories;
  </code></pre>
  <p>But it's not working. It returns empty.</p>
  <p>I feel like I'm close but I'm making a noob mistake. If anybody can point me in the right direction that would be great.</p>