3v4l.org

run code in 300+ PHP versions simultaneously
<?php $template = ['A', 'B', 'C']; $myArray = [ new Element('B'), new Element('C'), new Element('A'), ]; class Element { public $name; public function __construct($name) { $this->name = $name; } } usort($myArray, function($a, $b) use ($template) { return array_search($template, $a) - array_search($template, $b); }); var_dump($myArray);
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught TypeError: array_search(): Argument #2 ($haystack) must be of type array, Element given in /in/FnY8k:22 Stack trace: #0 /in/FnY8k(22): array_search(Array, Object(Element)) #1 [internal function]: {closure}(Object(Element), Object(Element)) #2 /in/FnY8k(21): usort(Array, Object(Closure)) #3 {main} thrown in /in/FnY8k on line 22
Process exited with code 255.

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