3v4l.org

run code in 300+ PHP versions simultaneously
<?php ini_set('date.timezone', 'Europe/London'); class OnlyPendingDeletionIterator extends FilterIterator implements Countable { public function __construct(array $items) { parent::__construct(new ArrayIterator($items)); } public function accept() { $item = $this->current(); $fourthOfJan = strtotime('2014-01-04'); return $fourthOfJan > strtotime($item['date']); } public function count() { return iterator_count($this); } } $items = array( array('id' => 1, 'date' => '2014-01-01'), array('id' => 2, 'date' => '2014-01-02'), array('id' => 3, 'date' => '2014-01-03'), array('id' => 4, 'date' => '2014-01-04'), array('id' => 5, 'date' => '2014-01-05'), array('id' => 6, 'date' => '2014-01-06'), array('id' => 7, 'date' => '2014-01-07'), ); $items = new OnlyPendingDeletionIterator($items); echo 'Pending: ', count($items), PHP_EOL; foreach ($items as $item) { echo 'id: ', $item['id'], PHP_EOL; }
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: Return type of OnlyPendingDeletionIterator::accept() should either be compatible with FilterIterator::accept(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/t4Y28 on line 10 Deprecated: Return type of OnlyPendingDeletionIterator::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/t4Y28 on line 16 Pending: 3 id: 1 id: 2 id: 3

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
47.11 ms | 402 KiB | 8 Q