SyntaxFix
Write A Post
Hire A Developer
Questions
Use this:
$json_data = json_encode($posts); file_put_contents('myfile.json', $json_data);
You have to create the myfile.json before you run the script.