How to remove `null` result when using array_unique?
<p>I have the following multidimensional array:</p>

<pre><code>$subregion = [
    [
        "subregion_id"   =&gt; "8",
        "subregion_name" =&gt; "NORTH_AMERICA",
        "subregion_abbr" =&gt; "US"
    ],
    [
        "subregion_id"   =&gt; "9",
        "subregion_name" =&gt; "NORTH_AMERICA",
        "subregion_abbr" =&gt; "CA"
    ],
    [
        "subregion_id"   =&gt; "6",
        "subregion_name" =&gt; "WE",
        "subregion_abbr" =&gt; "South"
    ],
    [
        "subregion_id"   =&gt; "0",
        "subregion_name" =&gt; null,
        "subregion_abbr" =&gt; null
    ],
    [
        "subregion_id"   =&gt; "5",
        "subregion_name" =&gt; "WE",
        "subregion_abbr" =&gt; "North"
    ],
    [
        "subregion_id"   =&gt; "0",
        "subregion_name" =&gt; null,
        "subregion_abbr" =&gt; null
    ]
];
</code></pre>

<p>I want to unique that array by its values so I have test the following (from <a href="https://stackoverflow.com/questions/307674/how-to-remove-duplicate-values-from-a-multi-dimensional-array-in-php">this post</a>):</p>

<pre><code>$subregion = array_map("unserialize", array_unique(array_map("serialize", $subregion)));
$subregion = array_intersect_key($subregion, array_unique(array_map('serialize', $subregion)));
$subregion_unique = array_unique($subregion, SORT_REGULAR);
</code></pre>

<p>All of them work (tried one by one) and produces the same output:</p>

<pre><code>$subregion = [
    [
        "subregion_id"   =&gt; "8",
        "subregion_name" =&gt; "NORTH_AMERICA",
        "subregion_abbr" =&gt; "US"
    ],
    [
        "subregion_id"   =&gt; "9",
        "subregion_name" =&gt; "NORTH_AMERICA",
        "subregion_abbr" =&gt; "CA"
    ],
    [
        "subregion_id"   =&gt; "6",
        "subregion_name" =&gt; "WE",
        "subregion_abbr" =&gt; "South"
    ],
    [
        "subregion_id"   =&gt; "5",
        "subregion_name" =&gt; "WE",
        "subregion_abbr" =&gt; "North"
    ],
    [
        "subregion_id"   =&gt; "0",
        "subregion_name" =&gt; null,
        "subregion_abbr" =&gt; null
    ]
];
</code></pre>

<p>I want to get rid of the <code>null</code> values on the array because them should not be there. So I have tried this other workaround (<a href="https://stackoverflow.com/a/20676918/719427">found here</a>):</p>

<pre><code>private function is_not_null($var)
{
    return !is_null($var);
}

$unique = array_filter($subregion_unique, 'is_not_null');
</code></pre>

<p>But surprise the output of <code>$unique</code> is exactly the same as before, why? What I am missing here?</p>

<p><strong>NOTE</strong> I forgot to mention that should be compatible with PHP 5.3.10+</p>

<p><strong>Update: test1</strong></p>

<p>Following @abracadaver instructions this is what I've tried:</p>

<pre><code>$unique = array_map('unserialize', array_unique(array_map('serialize', $subregion)));
$unique = array_map(function($v) { return array_filter($v, 'is_not_null'); }, $unique);
</code></pre>

<p>I have changed the function <code>is_not_null($var)</code> above to return result in this way:</p>

<pre><code>return null !== $var;
</code></pre>

<p>The result is an array with <code>null</code> values.</p>

<p>PS: Maybe the title is not accurate and the post is tempted to be closed or marked as duplicate, if so please suggest me a better title or change by yourself if you can. </p>