title: get unique views for specific posts
body: <p>I need to show monthly unique views count for specific pages. So for reaching that I did below:</p>
  
  <pre><code>$fullArray = array();
  $productIds = '100,200,210,220,255'; /* these are specific product ids */
  $idsArray = explode(',',$productIds);
  foreach ($idsArray as $unique_id_item) {
      $currentUniqueViews = $wpdb-&gt;get_results("
          SELECT DISTINCT IP as all_uniques, DATE_FORMAT( insertion_date, '%b' ) as 
          month_name, DATE_FORMAT( insertion_date, '%Y-%M' ) as full_date FROM
          daily_unique_views WHERE page_id = '".$unique_id_item."'
      ");
      if($currentUniqueViews){
          $fullArray[] = $currentUniqueViews;
      }
  }
  $encodedArray = json_decode(json_encode($fullArray), True);
  var_dump($encodedArray);
  </code></pre>
  
  <p>And above returns this:</p>
  
  <pre><code>array(5) {
    [0]=&gt;
    array(1) {
      [0]=&gt;
      array(3) {
        ["all_uniques"]=&gt;
        string(13) "111.11.11.111"
        ["month_name"]=&gt;
        string(3) "Dec"
        ["full_date"]=&gt;
        string(13) "2016-December"
      }
    }
    [1]=&gt;
    array(4) {
      [0]=&gt;
      array(3) {
        ["all_uniques"]=&gt;
        string(13) "111.11.11.111"
        ["month_name"]=&gt;
        string(3) "Oct"
        ["full_date"]=&gt;
        string(12) "2016-October"
      }
      [1]=&gt;
      array(3) {
        ["all_uniques"]=&gt;
        string(13) "111.11.11.111"
        ["month_name"]=&gt;
        string(3) "Nov"
        ["full_date"]=&gt;
        string(13) "2016-November"
      }
      [2]=&gt;
      array(3) {
        ["all_uniques"]=&gt;
        string(13) "122.12.12.122"
        ["month_name"]=&gt;
        string(3) "Dec"
        ["full_date"]=&gt;
        string(13) "2016-December"
      }
      [3]=&gt;
      array(3) {
        ["all_uniques"]=&gt;
        string(13) "111.11.11.111"
        ["month_name"]=&gt;
        string(3) "Dec"
        ["full_date"]=&gt;
        string(13) "2016-December"
      }
    }
    [2]=&gt;
    array(2) {
      [0]=&gt;
      array(3) {
        ["all_uniques"]=&gt;
        string(13) "111.11.11.111"
        ["month_name"]=&gt;
        string(3) "Nov"
        ["full_date"]=&gt;
        string(13) "2016-November"
      }
      [1]=&gt;
      array(3) {
        ["all_uniques"]=&gt;
        string(13) "111.11.11.111"
        ["month_name"]=&gt;
        string(3) "Dec"
        ["full_date"]=&gt;
        string(13) "2016-December"
      }
    }
    [3]=&gt;
    array(3) {
      [0]=&gt;
      array(3) {
        ["all_uniques"]=&gt;
        string(13) "111.11.11.111"
        ["month_name"]=&gt;
        string(3) "Nov"
        ["full_date"]=&gt;
        string(13) "2016-November"
      }
      [1]=&gt;
      array(3) {
        ["all_uniques"]=&gt;
        string(13) "111.11.11.111"
        ["month_name"]=&gt;
        string(3) "Dec"
        ["full_date"]=&gt;
        string(13) "2016-December"
      }
      [2]=&gt;
      array(3) {
        ["all_uniques"]=&gt;
        string(12) "71.111.1.111"
        ["month_name"]=&gt;
        string(3) "Dec"
        ["full_date"]=&gt;
        string(13) "2016-December"
      }
    }
    [4]=&gt;
    array(1) {
      [0]=&gt;
      array(3) {
        ["all_uniques"]=&gt;
        string(13) "111.11.11.111"
        ["month_name"]=&gt;
        string(3) "Dec"
        ["full_date"]=&gt;
        string(13) "2016-December"
      }
    }
  }
  </code></pre>
  
  <p>How you notice, array contains duplicated arrays. For example, below array repeats 5 times.</p>
  
  <pre><code>array(3) {
      ["all_uniques"]=&gt;string(13) "111.11.11.111"
      ["month_name"]=&gt;string(3) "Dec"
      ["full_date"]=&gt;string(13) "2016-December"
  }
  </code></pre>
  
  <p>How can I find and remove those duplicated arrays so that my unique views will be counted properly and in this case this ip (111.11.11.111) will be repeated only once for december and only once for november.</p>
  
  <p>I tried below but it doesn't give me desired result and some ips are missing in array:</p>
  
  <pre><code>array_diff_assoc( $encodedArray, array_unique( $encodedArray ) );
  </code></pre>
  
  <p>Any ideas please?</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>I also tried to use count() function. Count works fine, but duplicated IP count is still in that final count. My query looks like this:</p>
  
  <pre><code>$wpdb-&gt;get_results("SELECT COUNT(DISTINCT IP) as all_uniques, DATE_FORMAT( insertion_date,
  '%b' ) as month_name, DATE_FORMAT( insertion_date,'%Y-%M' ) as full_date FROM
  post_daily_unique_views WHERE page_id = '".$unique_id_item."'");
  </code></pre>