<p>You can use similar logic that Craft uses for the <a href="https://craftcms.com/classreference/etc/templating/twigextensions/CraftTwigExtension#withoutFilter-detail" rel="nofollow">withoutFilter</a> in <a href="https://craftcms.com/classreference/etc/templating/twigextensions/CraftTwigExtension" rel="nofollow">CraftTwigExtension</a>.</p>

<pre><code>public function withoutFilter($arr, $exclude)
{
    $filteredArray = array();

    if (!is_array($exclude))
    {
        $exclude = array($exclude);
    }

    foreach ($arr as $key =&gt; $value)
    {
        if (!in_array($value, $exclude))
        {
            $filteredArray[$key] = $value;
        }
    }

    return $filteredArray;
}
</code></pre>

CC BY-SA 3.0
2016-04-06T18:31:17.540Z
@RitterKnight That's what I get for posting before coffee.
Brad Bell
CC BY-SA 3.0
2016-04-06T18:32:41.060Z
Been there, done that!
RitterKnight
CC BY-SA 3.0
2016-04-06T17:16:57.353Z
2016-04-06T18:28:19.927Z
2016-04-06T18:28:19.927Z
Brad Bell
<p>I have and array of with <code>allEntries</code> and an array with <code>alreadyUpdatedEntries</code>. I would like to filter out all the <code>alreadyUpdatedToEntries</code> to end up with an array of <code>notUpdatedEntries</code>. Like how it is done in Twig.</p>

<pre><code>{% set notUpdatedEntries = allEntries|without(alreadyUpdatedEntries) %}
</code></pre>

<p>Is there a similar Craft PHP method to do this in my plugin? Can I maybe include this in my elements criteria query?</p>

<plugin-development>
How to apply a "without" filter in a plugin
# How to apply a "without" filter in a plugin

(Asked by: username_0 on 2016-04-06)

I have and array of with allEntries and an array with alreadyUpdatedEntries. I would like to filter out all the alreadyUpdatedToEntries to end up with an array of notUpdatedEntries. Like how it is done in Twig.
{% set notUpdatedEntries = allEntries|without(alreadyUpdatedEntries) %}

Is there a similar Craft PHP method to do this in my plugin? Can I maybe include this in my elements criteria query?

**Tags:** plugin-development


---

## 1 answers

### Answer by username_1 on 2016-04-06. Score: 0 | Accepted answer

You can use similar logic that Craft uses for the withoutFilter in CraftTwigExtension.
public function withoutFilter($arr, $exclude)
{
    $filteredArray = array();

    if (!is_array($exclude))
    {
        $exclude = array($exclude);
    }

    foreach ($arr as $key => $value)
    {
        if (!in_array($value, $exclude))
        {
            $filteredArray[$key] = $value;
        }
    }

    return $filteredArray;
}

> **Comments:**
> **username_1**: @username_2 That's what I get for posting before coffee.  
> **username_2**: Been there, done that!  

---

