public function test_array_reject() { $this->assertEquals(array(), array_reject(array(), array('foo', 'bar', 'baz'))); $this->assertEquals(array('bzz' => 'bar'), array_reject(array('bzz' => 'bar'), array('foo', 'bar', 'baz'))); $this->assertEquals(array(), array_reject(array('foo' => 'bar'), array('foo', 'bar', 'baz'))); $this->assertEquals(array(), array_reject(array('foo' => 'bar'), 'foo', 'bar')); $this->assertEquals(array('foo' => 'bar'), array_reject(array('foo' => 'bar'), 'bar')); }
<?php error_reporting(0); require 'helpers.php'; $time = milliseconds(); # Load our items $path = dirname(__FILE__); $items = yaml_decode_file("{$path}/items.yml"); # Now sort them, newest to oldest... $items = array_reverse(array_sort_by_key($items, 'published_at')); # ...and skip forward-dated items $items = array_reject($items, '$item[\'published_at\'] <= ' . time());