Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-04-06T18:31:17.540Z
Answers.Text: @RitterKnight That's what I get for posting before coffee.
Answers.UserDisplayName: Brad Bell
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-04-06T18:32:41.060Z
Answers.Text: Been there, done that!
Answers.UserDisplayName: RitterKnight
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-04-06T17:16:57.353Z
Answers.LastActivityDate: 2016-04-06T18:28:19.927Z
Answers.LastEditDate: 2016-04-06T18:28:19.927Z
Answers.UserDisplayName: Brad Bell
Body: <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>
  
Tags: <plugin-development>
Title: How to apply a "without" filter in a plugin
ThreadText: # 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](https://craftcms.com/classreference/etc/templating/twigextensions/CraftTwigExtension#withoutFilter-detail) in [CraftTwigExtension](https://craftcms.com/classreference/etc/templating/twigextensions/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!  
  
  ---
  
  