3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $array = array( 'index1' => 'Deleted', 'index2' => 'numbers', 'index3' => 'test', 'index4' => 'Inserted', ); $specificIndex = array('index2','index3'); $array1=array(); foreach($array as $key => $value){ if($key == $specificIndex){ $array1[$key] = $value; unset($array[$specificIndex]); } } print_r($array); print_r($array1);
based on K803S
Output for 4.3.0 - 7.2.0
Array ( [index1] => Deleted [index2] => numbers [index3] => test [index4] => Inserted ) Array ( )