3v4l.org

run code in 300+ PHP versions simultaneously
<?php function searchFromArray($array, $keyword) { echo "\n".$keyword."\n"; $result = array(); if (count($keyword) == 2) { $result[] = $array[$keyword[0]]; } else { foreach ($keyword as $kw => $vw) { if (isset($array[$vw])) { if (is_array($array[$vw])) { unset($keyword[0]); searchFromArray($array[$vw], $keyword); } else { $result[] = $array[$vw]; } } } } return $result; } $array_search = array( 'offset' => '', 'count' => '', 'max_count' => '', 'content_list' => array(array( 'content' => array( 'id'=>'1', 'type'=>'', 'name_title'=>'', 'parent_id'=>'', 'rating_type'=>'', 'link_url'=>'', 'tag' => array( 'id' => 'tag_id_1', 'name' => 'tag_name_1' ), 'image_dir'=>'', 'image_url'=>'', 'image_dir_thumb'=>'x', 'image_url_thumb'=>'' ), 'content' => array( 'id'=>'2', 'type'=>'', 'name_title'=>'', 'parent_id'=>'', 'rating_type'=>'', 'link_url'=>'', 'tag' => array( 'id' => 'tag_id_2', 'name' => 'tag_name_2' ), 'image_dir'=>'', 'image_url'=>'', 'image_dir_thumb'=>'y', 'image_url_thumb'=>'' ) ) ) ); $keyword = array('content_list', 'content', 'tag'); $result = searchFromArray($array_search, $keyword); var_dump($result);
Output for git.master, git.master_jit, rfc.property-hooks
Warning: Array to string conversion in /in/UPO8P on line 4 Array Warning: Array to string conversion in /in/UPO8P on line 4 Array Warning: Undefined array key 0 in /in/UPO8P on line 8 Warning: Undefined array key "" in /in/UPO8P on line 8 array(0) { }

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:
72.45 ms | 402 KiB | 8 Q