3v4l.org

run code in 300+ PHP versions simultaneously
<?php $nu_array = null; $callback = function ( $item ) use(&$nu_array) { if (!is_array($item)) { $nu_array[] = $item; } else if ( is_array( $item ) ) { foreach( array_values($item) as $v) { if ( !(is_array($v))) { $nu_array[] = $v; } else { $callback( $v ); continue; } } } }; $array = array( 'a',array(1,2), 'b',array(3,4, array(5,6, array('c', array(7,8)))) ); array_walk($array, $callback); print_r($nu_array); /** Array ( [0] => a [1] => 1 [2] => 2 [3] => b [4] => 3 [5] => 4 [6] => 5 [7] => 6 [8] => c [9] => 7 [10] => 8 ) **/
Output for git.master, git.master_jit, rfc.property-hooks
Warning: Undefined variable $callback in /in/l26Xg on line 15 Fatal error: Uncaught Error: Value of type null is not callable in /in/l26Xg:15 Stack trace: #0 [internal function]: {closure}(Array, 3) #1 /in/l26Xg(24): array_walk(Array, Object(Closure)) #2 {main} thrown in /in/l26Xg on line 15
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:
38 ms | 401 KiB | 8 Q