<?php $array = [ [ 'id' => 1, 'name' => 'John', 'address' => 'Some address 1', 'city' => 'NY' ], [ 'id' => 2, 'name' => 'Jack', 'address' => 'Some address 2', 'city' => 'NY' ] ]; $keep = ['id' => '', 'name' => '']; var_export( array_map( fn($row) => array_intersect_key($row, $keep), $array ) );
You have javascript disabled. You will not be able to edit any code.