I am working on a project to create 2 column CSV using PHP and i have the data stored as strings in 2 different variables . Consider below example of what i have and what i need further. Thank you in advance.
I have below 2 variables and data stored inside them. (data is separated by comma)
$title = title1,title2,title3,title4,title5..and so on
$values = value1,value2,value3,value4,value5..and so on
I need this array pattern like this
$multi_array = array
(
array(title1,value1),
array(title2,value2),
array(title3,value3),
);
I will then use the below code to generate 2 column CSV via PHP
// open the file "demosaved.csv" for writing
$file = fopen('demosaved.csv', 'w');
// save the column headers
fputcsv($file, array('Column 1', 'Column 2'));
// save each row of the data
foreach ($multi_array as $row)
{
fputcsv($file, $row);
}
// Close the file
fclose($file);