title: PHP: array_filter for an object?
body: <p>I have an array that I need to filter for certain things, for example, I might only want records that have the day of the week as Friday. As far as I'm aware this has never worked but it's taking an object and using <code>array_filter</code> on it. Can this work? Is there a better way or a way to do this on with object?</p>
  
  <pre><code>public function filterByDow($object)
  {
      $current_dow=5;
      return array_values(array_filter($object, function ($array) use ($current_dow) {
          $array = (array) $array;
              if(!empty($array['day_id']) &amp;&amp; $array['day_id'] &gt; -1){
                  if($array['day_id'] != $current_dow){
                      return false;
                  }
              }
              return true;
      }));
  }
  
  $object = $this-&gt;filterByDow($object);
  </code></pre>
  
  <p>Sample data might be like: </p>
  
  <pre><code>$object = (object) array(['id' =&gt; '1', 'day_id' =&gt; 3], ['id' =&gt; '2', 'day_id' =&gt; 4]);
  </code></pre>