I\'m trying to create a short PHP script that takes a JSON string, converts it to CSV format (using fputcsv), and makes that CSV available as a downloaded .csv file
json_decode() by default translates elements into objects rather than arrays. fputcsv() expects the data passed to be an array.
I'd recommend changing:
$jsonArray = json_decode( $_POST['json'] );
To:
$jsonArray = json_decode( $_POST['json'], True );
And see if that doesn't fix your problem.
When attempting to tackle problems such as these I'd highly recommend enabling display_errors and setting error_reporting to E_ALL to see if there some sort of error you are missing out on: