-2

Is there any PHP code that could transform or convert these array into a CSV file?

Array ( [0] => rubbish [1] => bad [2] => hate [3] => abandoned [4] => abused [5] => accused [6] => addicted [7] => afraid [8] => aggravated [9] => aggressive [10] => alone [11] => angry [12] => anguish [13] => annoyed [14] => anxious [15] => apprehensive [16] => argumentative [17] => artificial [18] => ashamed [19] => assaulted [20] => atrocious [21] => attacked [22] => avoided [23] => awful [24] => awkward [25] => badgered [26] => baffled [27] => banned [28] => barren [29] => beat [30] => beaten )

kara
  • 3,205
  • 4
  • 20
  • 34
qwerty
  • 1
  • 1

1 Answers1

0

You can use fopen and fputcsv function to write in csv file. Make sure the path is writable.

$rowData = array(
    array(1,2,3),
    array(1,2,3),
);

$fp = fopen('test.csv', 'w');

foreach ($rowData as $fields) {
    fputcsv($fp, $fields);
}
fclose($fp);

For more details please refer to PHP Manual

Rakesh Jakhar
  • 6,380
  • 2
  • 11
  • 20