I need to push some JSON data to my website which I would like to read in PHP. What type of file should I make this? A PHP file with the JSON inside of a variable? I understand how to make a text file with JSON encoded data in it, but how do I get this into PHP? Should I use a PHP include with the JSON-encoded data in it assigned to a variable? Or should I read the file from PHP and put the contents into a variable?
Share
Save your json string as plain text, then you can use:
See
file_get_contents()andjson_decode().The advantage of doing this (versus storing it in a PHP file then including it) is that now any program or language that understands JSON can read the file.