0 => array[
"id" => "94e568e2-e5ef-4565-b9d1"
"code" => "8899014500001"
"name" => "John"
"age" => "24" ]
I'm trying to convert an array of users into a CSV file. And i set the array of the key that I want to export.
$fields = ['id', 'name'];
How can I fputcsv in foreach loop return only user id and name from $fields array ?
foreach ($user as $item) {
fputcsv($output, $item);
}