it's my first post here, I'm a beginner and I hope you'll go easy on me. I searched for an answer, and read some semi-related questions. I've been stuck on this for a couple days and I really am very confused. Apologies if the double barrelled is a faux pas, it seemed less sensible to write this as two seperate questions. I'm new to programming and I had never heard of this website until yesterday, I hope to be a contributing part of what seems to be an awesome community.
I have an array, $newarray:
Array
(
[2] => string1,10
[7] => string2,15
[10] => string3,3
[11] => string4,7
)
I'm able to write it to a CSV file, and so far so good:
<?php
$file = fopen("/myfile.csv","w");
foreach ($newarray as $line)
{
fputcsv($file,explode(',',$line));
}
fclose($file);
?>
However, I'm trying to do two things.
Sorting the array by reverse order of the numerical values before writing to CSV, so I would have a CSV file as so:
string2,15 string1,10 string4,7 string3,3Create a second file (after writing the first CSV), where the numerical values are stripped out, as so:
string2 string1 string4 string3
Can someone steer me in the right direction?
Array ( 2 => 'string1,10', 7 => 'string2,15', 10 => 'string3,3', 11 => 'string4,7', );?