Is there a native function to remove multiple indexes from an array and then return source array without removed objects or vice versa, to keep only required indexes while removing the rest.
Example:
$source = array('index1' => 1, 'index2' => 2, 'index3' => 3, 'index4' => 4);
json_encode( array_extract( $source, array('index2','index4'))); // returns array('index2' => 2, 'index4' => 4);
or:
json_encode( array_except( $source, array('index1','index4'))); // returns array('index2' => 2, 'index3' => 3);