3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Example input #1 $ex_input_1 = array( 'files' => array( 0 => array( 'name' => 'file.jpg', 'size' => '244235', 'tmp_name' => '/usr/tmp/24ffds.tmp', 'error' => 0 ), 1 => array( 'name' => '', 'size' => '', 'tmp_name' => '', 'error' => 4 ) ), 'cover' => array( 'name' => '', 'size' => '', 'tmp_name' => '', 'error' => 4 ), 'document' => array( 'name' => 'file.doc', 'size' => '244235', 'tmp_name' => '/usr/tmp/24ffds.tmp', 'error' => 0 ) ); // Example input #2 $ex_input_2 = array( 0 => array( 'name' => 'file.jpg', 'size' => '244235', 'tmp_name' => '/usr/tmp/24ffds.tmp', 'error' => 0 ), 1 => array( 'name' => '', 'size' => '', 'tmp_name' => '', 'error' => 4 ) ); function array_filter_recursive($array) { if (isset($array['error'])) { // bottom of tree return $array['error'] == 4 ? array() : $array; } foreach ($array as $key => $value) { $array[$key] = array_filter_recursive($value); } // remove any empty values return array_filter($array); } print_r(array_filter_recursive($ex_input_1)); print_r(array_filter_recursive($ex_input_2));
Output for git.master_jit, git.master, rfc.property-hooks
Array ( [files] => Array ( [0] => Array ( [name] => file.jpg [size] => 244235 [tmp_name] => /usr/tmp/24ffds.tmp [error] => 0 ) ) [document] => Array ( [name] => file.doc [size] => 244235 [tmp_name] => /usr/tmp/24ffds.tmp [error] => 0 ) ) Array ( [0] => Array ( [name] => file.jpg [size] => 244235 [tmp_name] => /usr/tmp/24ffds.tmp [error] => 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:
82.22 ms | 407 KiB | 5 Q