---
layout: default
title: WP_CLI\Utils\write_csv()
description: "Write data as CSV to a given file."
---

<small><a href="/docs/">Docs</a> &raquo; <a href="/docs/internal-api/">Internal API</a> &raquo; Misc</small>

## WP_CLI\Utils\write_csv()

Write data as CSV to a given file.

***

### Usage

    WP_CLI\Utils\write_csv( $fd, $rows, $headers = array() )

<div>
<strong>$fd</strong> (resource) File descriptor<br />
<strong>$rows</strong> (array) Array of rows to output<br />
<strong>$headers</strong> (array) List of CSV columns (optional)<br />
</div>


*Internal API documentation is generated from the WP-CLI codebase on every release. To suggest improvements, please submit a pull request.*


***

### Related

<ul>



<li><strong><a href="/docs/internal-api/wp-cli-utils-http-request/">WP_CLI\Utils\http_request()</a></strong> - Make a HTTP request to a remote URL.</li>


<li><strong><a href="/docs/internal-api/wp-cli-utils-get-named-sem-ver/">WP_CLI\Utils\get_named_sem_ver()</a></strong> - Compare two version strings to get the named semantic version.</li>


<li><strong><a href="/docs/internal-api/wp-cli-utils-parse-ssh-url/">WP_CLI\Utils\parse_ssh_url()</a></strong> - Parse a SSH url for its host, port, and path.</li>



</ul>


