ご注意!

この記事には PHP コードが含まれており、開発者を対象としています。このコードは便宜上提供していますが、コードのカスタマイズやサードパーティの開発についてはサポートを提供していません。

追加のガイダンスについては、WPBeginner の カスタムコードの追加方法に関するチュートリアル を参照してください。

閉じる

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!

セットアップ

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