I need to write an array to a .csv file in PHP.
Example array:
$array = array(
"name" => "John",
"surname" => "Doe",
"email" => "nowhere@nowhere.com"
);
By using implode(",", $array), I get a result like this:
John,Doe,nowhere@nowhere.com
However, I need to also write the key of each element to the file.
The desired output is this:
name:John,surname:Doe,email:nowhere@nowhere.com
How would I achieve this?
Try this code: