3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { public $val; public function __construct($val) { $this->val = $val; } } $storage = new SplObjectStorage; for($i = 1; $i <= 10; $i++) { $storage->attach(new A($i)); } $iterations = 0; $storage->rewind(); while ($storage->valid()) { $iterations++; $object = $storage->current(); //echo 'Iteration #' . $iterations . ' with object A(' . $object->val . ')'; $storage->next(); if($iterations === 2 || $iterations === 8) { $storage->detach($object); //echo ' - deleted Object A(' . $object->val . ') '; } //echo PHP_EOL; } echo 'Number of iterations: ' . $iterations . PHP_EOL;
Output for git.master, git.master_jit, rfc.property-hooks
Number of iterations: 16

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:
54.53 ms | 401 KiB | 8 Q