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 way to parse the php variable inside a json file.
Below is the code: test.json
{
"result":"$result",
"count":3
}
php script for accessing the json file
<?php
$result = 'Hello';
$event = file_get_contents('test.json');
echo $event;
?>
Now the output is like below:
{ "result":"$result", "count":3 }
But I need the output like this
{ "result":"Hello", "count":3 }
I'm not able to access the $result
variable inside a json file.
Any help Appreciated.Thanks