the latest version requires php 7+ but the old 8.x branch can work with a lower version of php so you can download it from: https://github.com/thephpleague/csv/tree/8.2.2

[code]
<?php // https://github.com/thephpleague/csv/blob/8.x/examples/writing.php include_once 'shared/csv-8.2.2/autoload.php'; use League\Csv\Writer; // http://csv.thephpleague.com/8.0/bom/ //$writer->setOutputBOM(Writer::BOM_UTF8); //adding the BOM sequence on output

$header = ["position" , "team", "played", "goals difference", "points"];
$records = [
[1, "Chelsea", 26, 27, 57],
[2, "Arsenal", 26, 22, 56],
[3, "Manchester City", 25, 41, 54,],
[4, "Liverpool", 26, 34, 53],
[5, "Tottenham", 26, 4, 50],
[6, "Everton", 25, 11, 45],
[7, "Manchester United", 26, 10, 42],
];

$writer = Writer::createFromPath('./file.csv', 'w');
$writer->insertOne($header);
$writer->insertAll($records);
[/code]

Referral Note: When you purchase through an referral link (if any) on our site, we earn a commission.