3v4l.org

run code in 300+ PHP versions simultaneously
<?php $result = []; $init_arr = [ ['name'=>'grape','num'=>2], ['name'=>'melon','num'=>1] ]; $result['init_arr'] = $init_arr; $removed_arr = my_remove_data( $init_arr, 2 ); $result['removed_arr'] = $removed_arr; array_unshift( $init_arr, ['name'=>'apple','num'=>3] ); $result['added_arr'] = $init_arr; var_dump( $result ); function my_remove_data( $arr, $id ){ foreach($arr as $k1=>$a) { foreach($a as $k2=>$b) { if($b == $id) { unset($arr[$k1]); } } } return $arr; }
Output for git.master, git.master_jit, rfc.property-hooks
array(3) { ["init_arr"]=> array(2) { [0]=> array(2) { ["name"]=> string(5) "grape" ["num"]=> int(2) } [1]=> array(2) { ["name"]=> string(5) "melon" ["num"]=> int(1) } } ["removed_arr"]=> array(1) { [1]=> array(2) { ["name"]=> string(5) "melon" ["num"]=> int(1) } } ["added_arr"]=> array(3) { [0]=> array(2) { ["name"]=> string(5) "apple" ["num"]=> int(3) } [1]=> array(2) { ["name"]=> string(5) "grape" ["num"]=> int(2) } [2]=> array(2) { ["name"]=> string(5) "melon" ["num"]=> int(1) } } }

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:
28.77 ms | 407 KiB | 5 Q