3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = array("A" => "aa", "B" => ["A" => "aaa", "B" => "bb"], "C" => "cc", "D" => ["E" =>"ee"]); function array_filter_recursive(array &$array, callable $callback) { foreach ($array as $key => &$value) { if ($callback($key, $value)) unset($array[$key]); else if (is_array($value)) array_filter_recursive($value, $callback); } } function sanitizedArray(&$arr, $restricted, $keys = false) { foreach($restricted as $val) { array_filter_recursive($arr, function($k, $v) use ($val, $keys) {return $keys ? ($val === $k) : ($val === $v);}); } } sanitizedArray($arr, ["A","E", "D"], true); print_r($arr);
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [B] => Array ( [B] => bb ) [C] => cc )

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