title: How do I return a unique list based on JSON results in PHP?
body: <p>I’m attempting to use the values from one JSON link to populate values in other JSON links resulting in a unique list of values from the combined JSON.  I’ve gotten as far as creating the complete list of values, but I’m having a difficult time finding the syntax in the final loop to display only the unique values.  Any help would be appreciated.</p>
  
  <pre><code>$collection_string = file_get_contents("http://some_json_url.com/json");
  $collection_list = json_decode($collection_string, true);
  
  foreach ($collection_list as $col_lists =&gt; $col_list) {
       $object_string = file_get_contents('http://another_json_url.com/'.$col_list['key'].'/json');
       $object_list = json_decode($object_string, true);
       $object_array = array();
  
       foreach ($object_list as $objects =&gt; $object) {
            $object_array [] = array_unique($object); //Returns "Warning: array_unique() expects parameter 1 to be array, string given in..."
            echo '&lt;li&gt;&lt;a href="some_search_url/'.$object_array.'/search/"&gt;'.$object_array.'&lt;/a&gt;&lt;/li&gt;'; //Returns "Array"
            echo '&lt;li&gt;&lt;a href="some_search_url/'.$object.'/search/"&gt;'.$object.'&lt;/a&gt;&lt;/li&gt;'; //Returns complete list
       }
  
  }
  </code></pre>
  
  <p>Working code:</p>
  
  <pre><code>$collection_string = file_get_contents("http://some_json_url.com/json");
  $collection_list = json_decode($collection_string, true);
  
  $object_array = array();
  
  foreach ($collection_list as $col_lists =&gt; $col_list) {
       $object_string = file_get_contents('http://another_json_url.com/'.$col_list['key'].'/json');
       $object_list = json_decode($object_string, true);
  
       foreach ($object_list as $key =&gt; $value) {
            array_push($object_array, $value);
       }
  }
  
  $object_unique = array_unique($object_array);
  natcasesort($object_unique);
  
  foreach ($object_unique as $key =&gt; $value) {
       echo '&lt;li&gt;&lt;a href="some_search_url/'.$value.'/search/"&gt;'.$value.'&lt;/a&gt;&lt;/li&gt;';
  }
  </code></pre>