A few months ago I wrote a quick post showing how to parse JSONC (JSON with comments) files in JavaScript. Shortly thereafter I adapted the code to work in PHP as well:

This function takes the same arguments that you can pass to the native json_decode() function. Besides removing JavaScript style comments, this will also ignore trailing commas. Feel free to try this code out in your projects. Let me know if you have any comments, suggestions or issues and as always, happy coding!!! šŸ˜Ž

Categories: BlogPHP

Leave a Reply

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