PHP $array[0] in $string for JSON
- by user1907696
I am trying to use PHP to make a JSON file. Part of the code is as follow
$array = array("hello", "world");
$string='{"person": [
{
"name":'$array[0];',
"age":'$array[1];'
}
]
}';
The file created. However, $array[0] and $array[1] doesn't return the values "hello" and "world" but as $array[0] and $array[1]
Any idea?
Thanks