3v4l.org

run code in 300+ PHP versions simultaneously
<?php function isItEnd($array){ return !array_key_exists('ancestors', $array); } function getThirdFromEnd($category){ if(!isItEnd($category)){ $away_from_parent = getThirdFromEnd($category['ancestors']['BrowseNode']); if($away_from_parent == 0){ $away_from_parent = $category['ancestors']['BrowseNode']; } else { $away_from_parent--; } } else { $away_from_parent = 2; } return $away_from_parent; } $category = array( "BrowseNodeId" => "11256", "name"=> "Folklore & Mythology", "ancestors" => array( "BrowseNode" => array( "BrowseNodeId" => "11232", "name"=> "Social Sciences", "ancestors" => array( "BrowseNode" => array( "BrowseNodeId" => "3377866011", "name"=> "Politics & Social Sciences", "ancestors" => array( "BrowseNode" => array( "BrowseNodeId" => "1000", "name"=> "Subjects", "IsCategoryRoot" => true, "ancestors" => array( "BrowseNode" => array( "BrowseNodeId" => "283155", "name"=> "Books", ), ), ), ), ), ), ), ), ); $cat = getThirdFromEnd($category); echo "<pre>" . print_r($cat, 1) . "</pre>";
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught TypeError: Cannot decrement array in /in/SeKvM:13 Stack trace: #0 /in/SeKvM(51): getThirdFromEnd(Array) #1 {main} thrown in /in/SeKvM on line 13
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:
30.84 ms | 401 KiB | 8 Q