3v4l.org

run code in 300+ PHP versions simultaneously
<?php function transfer( $arr, $prefix=array(), $glue="_" ) { $res = array(); foreach( $arr as $key => $val ) { $key = array_merge( $prefix, array($key) ); if( is_array($val) ) $res = array_merge( $res, transfer( $val, $key, $glue ) ); else $res[ implode($glue, $key) ] = $val; } return $res; } $attributes = array( 'Users' => array( 'Name' => 'Name', ), 'Address' => 'Address', 'Tags' => array( 0 => array( 'Key' => 'Key', 'Value' => 'Value', ), 1 => array( 'Key' => 'Key', ), 2 => array( ) ), ); var_dump( transfer( $attributes ) );
Output for git.master, git.master_jit, rfc.property-hooks
array(5) { ["Users_Name"]=> string(4) "Name" ["Address"]=> string(7) "Address" ["Tags_0_Key"]=> string(3) "Key" ["Tags_0_Value"]=> string(5) "Value" ["Tags_1_Key"]=> string(3) "Key" }

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