Hi! Could we please enable some services and cookies to improve your experience and our website?
Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code
<?php
$arrays = [
['userId' => 1, 'coin' => 2.20 ],
['userId' => 5, 'coin' => 0.60 ],
['userId' => 1, 'coin' => 1.00 ],
['userId' => 31, 'coin' => 0.30 ],
['userId' => 1, 'coin' => 4.00 ],
['userId' => 31, 'coin' => 0.20 ],
['userId' => 31, 'coin' => 0.30 ],
['userId' => 5, 'coin' => 0.30 ]
];
print_r($arrays);
$out = fopen('php://output', 'w');
foreach($arrays as $arr) {
fputcsv($out, $arr);
}
fclose($out);