How do I remove one array from another in php?
<p>I have the following arrays in PHP: 
print_r($employees) = </p>

<pre><code>Array
(
    [0] =&gt; Array
        (
            [p_id] =&gt; T29083999
            [name] =&gt; Robert Plaxo
        )

    [1] =&gt; Array
        (
            [p_id] =&gt; T29083388
            [name] =&gt; Yvan Sergei
        )

    [2] =&gt; Array
        (
            [p_id] =&gt; T21083911
            [name] =&gt; Rhonda Saunders
        )

    [3] =&gt; Array
        (
            [p_id] =&gt; H02910382
            [name] =&gt; Miguel Mercado
        )
)
</code></pre>

<p>then this array: 
print_r($record) = </p>

<pre><code>Array
(
    [0] =&gt; Array
        (
            [c_id] =&gt; 1
            [section] =&gt; 1061
            [term] =&gt; 201631
            [p_id] =&gt; T29083388
            [c_date] =&gt; 2016-04-01 09:14:00
        )

)
</code></pre>

<p>I want to remove the array element from $employees that matches the p_id of $record. Array $record may have multiple entries like the one shown.  If so, any p_id in $record must be removed from $employees. </p>

<p>I tried: </p>

<pre><code>foreach ($employees as $k =&gt; $e) {
    foreach ($record as $r) {
        if ($e['p_id']==$r['p_id']) {
            echo "found it!";
            // if I uncomment the next line, it crashes! (500 server error)
            //  unset $employees[$k];
        }           
    }   
}
</code></pre>

<p>I just want to remove any element from $employees that has any employee that matches any record in $record with that employee id. </p>