3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = array( 'green' => 'keyword', 'orange', 'keyword', 'black' => array( 'purple' => 'text', 'brown', 'pink' => 'keyword' ), 'white' => array( 'red', 'yellow' => 'keyword', 'blue' ), 'violet', 'gray' ); $arr = array(); $str = 'keyword'; $arr[] = array_filter($array, function($var) use ($str) { global $arr; if(is_array($var)){ $arr[] = array_filter($var, function($var2) use ($str) { return preg_match("/$str/i", $var2); }); }else{ return preg_match("/$str/i", $var); } }); function getL2Keys($array){ $result = array(); foreach($array as $sub) { $result = array_merge($result, $sub); } return $result; } $arr = getL2Keys($arr); echo '<pre>'; print_r($arr);
Output for git.master, git.master_jit, rfc.property-hooks
<pre>Array ( [pink] => keyword [yellow] => keyword [green] => keyword [0] => keyword )

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