fork download
  1. <?php
  2.  
  3. $alpha = array('a','b','c','d','e','f');
  4.  
  5. $index = array(2,5);
  6.  
  7. function remove_keys($array, $indexes = array()){
  8. return array_intersect_key($array, array_diff(array_keys($array),$indexes));
  9. }
  10. var_dump(remove_keys($alpha,$index));
Success #stdin #stdout 0.02s 13112KB
stdin
Standard input is empty
stdout
array(4) {
  [0]=>
  string(1) "a"
  [1]=>
  string(1) "b"
  [3]=>
  string(1) "d"
  [4]=>
  string(1) "e"
}