3v4l.org

run code in 300+ PHP versions simultaneously
<?php class familyMember { var $memberId; var $familyId; var $firstName; var $age; var $hairColor; // ... } class family { var $familyId; var $name; var $members = array(); // array of familyMember objects var $sortFields = array(); var $sortDirections = array(); // ... function _objSort(&$a, &$b, $i = 0) { $field = $this->sortFields[$i]; $direction = $this->sortDirections[$i]; $diff = strnatcmp($this->details[$a]->$field, $this->details[$b]->$field) * $direction; if ($diff == 0 && isset($this->sortFields[++$i])) { $diff = $this->_objSort($a, $b, $i); } return $diff; } function sortMembers($sortFields) { $i = 0; foreach ($sortFields as $field => $direction) { $this->sortFields[$i] = $field; $direction == "DESC" ? $this->sortDirections[$i] = -1 : $this->sortDirections[$i] = 1; $i++; } uksort($this->details, array($this, "_objSort")); $this->sortFields = array(); $this->sortDirections = array(); } } // open a family $familyId = 5; $family = new family($familyId); $family->open(); // this will also fetch all members // sort members by 3 fields $family->sortMembers(array("firstName" => "ASC", "age" => "DESC", "hairColor" => "ASC")); // output all family members foreach ($family->members as $member) { echo $member->firstName." - ".$member->age." - ".$member->hairColor."<br />"; } ?>
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught Error: Call to undefined method family::open() in /in/Gi6EB:53 Stack trace: #0 {main} thrown in /in/Gi6EB on line 53
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:
50.62 ms | 401 KiB | 8 Q