3v4l.org

run code in 300+ PHP versions simultaneously
<?php function recursive_select($data, callable $callback, $flag = \RecursiveIteratorIterator::SELF_FIRST, $preserve_keys = FALSE) { return iterator_to_array(new \CallbackFilterIterator(new \RecursiveIteratorIterator(new \RecursiveArrayIterator($data), $flag), $callback), $preserve_keys); } $multi=[['A',['B',['CC','CCCC','CCCCCC'],['DDD','EFG','HIJ','LMNOP']]],['2'],'b',[[],[],[]]]; $array = array(1,2,[3,4],5,'six',array(array('78',9)),10); $multi_output = recursive_select($multi, function ($value) { return is_string($value); }); $array_output = recursive_select($array, function ($value) { return is_numeric($value) || is_string($value); }); var_dump($multi_output, $array_output);
Output for git.master, git.master_jit, rfc.property-hooks
array(11) { [0]=> string(1) "A" [1]=> string(1) "B" [2]=> string(2) "CC" [3]=> string(4) "CCCC" [4]=> string(6) "CCCCCC" [5]=> string(3) "DDD" [6]=> string(3) "EFG" [7]=> string(3) "HIJ" [8]=> string(5) "LMNOP" [9]=> string(1) "2" [10]=> string(1) "b" } array(9) { [0]=> int(1) [1]=> int(2) [2]=> int(3) [3]=> int(4) [4]=> int(5) [5]=> string(3) "six" [6]=> string(2) "78" [7]=> int(9) [8]=> int(10) }

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