$message_delivery_value, 'message_mandatory_value' => $message_mandatory_value, 'exchange_durable_value' => $exchange_durable_value, 'exchange_type_value' => $exchange_type_value, 'consumer_prefetch_value' => $consumer_prefetch_value, 'consumer_ack_value' => $consumer_ack_value, 'queue_durable_value' => $queue_durable_value, ]; } } } } } } } $fp = fopen('states.csv', 'w'); $h = [ 'message_delivery_value', 'message_mandatory_value', 'exchange_durable_value', 'exchange_type_value', 'consumer_prefetch_value', 'consumer_ack_value', 'queue_durable_value', ]; fputcsv($fp, $h); foreach ($r as $fields) { fputcsv($fp, $fields); } fclose($fp); });