I have created a local Json but not sure how to access this json array in php. Following is a small extract from the JSON file.
[
{
"EPIC": "PRU",
"Company Name": "Prudential PLC",
"Market Cap": 38946.60485268,
"Closing Price": 1498,
"Net Change": 38.5,
"% Change": 2.638,
"PE": 21.7211629087218,
"52W High": 1795,
"52W Low": 1299.5,
"Volume": 8465.537
},
{
"EPIC": "LGEN",
"Company Name": "Legal & General Group PLC",
"Market Cap": 16402.72850975,
"Closing Price": 275,
"Net Change": 7.3,
"% Change": 2.727,
"PE": 8.66360027723522,
"52W High": 292.3,
"52W Low": 214.9,
"Volume": 32031.848
}
]
Could someone please advise how can I access the elements of this array.
I have tried the following code with no result:
$strJsonFileContents = file_get_contents("FileNAME.json");
// Convert to array
$array = json_decode($strJsonFileContents);
echo $array->EPIC;
I would like to extract each element of the array and present it on the website in a tabular format.