I have a php script , it accessing a json file by using file_get_contents()
, inside a json file, we have declared a php variable. Please let me know is there any w
Instead of doing it your way like { "result":"$result", "count":3 }
I would have done like this.
I would have specified a short code for the variable for this
{ "result":"**result**", "count":3 }
and when I will get that JSON in PHP, just replace that with my desired PHP variable
$event = file_get_contents('test.json');
var $result = "hello";
$parsed_json = str_replace("**result**", $result,$event );