Categories : PHP

With FILE_APPEND flag you can add content into end of file.

Also you can sue PHP_EOL to add new line to file.

file_put_contents(__DIR__ . '/products.json', json_encode($product) . PHP_EOL, FILE_APPEND);

Leave a Reply

Your email address will not be published. Required fields are marked *