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);
No, because there is a small problem, your first array contains keys and your second array contains values. There is no function to achieve what you want.
There are multiple functions, array_intersect, array_diff, array_intersect_key, array_diff_key..but they all require matching arrays.