Export to csv file problem

I an trying to export to a csv file the values of an array put I have the error

Warning: fputcsv() expects parameter 2 to be array, string given

the code is bellow ,What I can do to solve it?

foreach ($array[$domain_id][$pr[1]] as $arr)
 $insert[ ] ="Some text from $array";
$fp = fopen('mart.csv', 'w');
 foreach ($insert as $fields) {
     fputcsv($fp, $fields);

I set the code bellow and I solved it.
$insert[ ] = array('select'=>"Some text from $array");

Welcome to the forums @dimis2831

When you post code in the forum, you need to format it. To do so you can either select all the code and click the </> button, or type 3 backticks ``` on a separate line both before and after the block of code.

I have done it for you this time.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.