How To Remove Line Breaks From CSV Exports

Overview

Would you like to remove the line breaks from CSV exports? For most fields such as Checkboxes and Address form fields you can add a small code snippet to remove these line breaks from your export file. In this tutorial, we’ll show you how!

Setup

Simply add this code snippet to your site.

/**
 * Removes line breaks from CSV data
 *
 * @link   https://wpforms.com/developers/how-to-remove-line-breaks-from-csv-exports/
 */

function wpf_dev_remove_line_breaks_csv( $export_data, $request_data, $entry ) {
	
	array_walk(
         $export_data,
         static function( &$row ) {
            $row = str_replace( "\n", ' ', $row );
         }
      );
 
      return $export_data;
	
}
add_filter( 'wpforms_pro_admin_entries_export_ajax_get_entry_data', 'wpf_dev_remove_line_breaks_csv', 10, 3 );

With this small snippet you've now removed line breaks from the CSV export

Filter Reference: wpforms_pro_admin_entries_export_ajax_get_entry_data