I have an issuse after reading json file with file_get_contents.
When I run this code, its working ok:
<?php
$json='[
{
"fullName":"Shachar Ganot",
"address":"Yad Rambam",
"phoneNumber":"050-1231233",
"email":"",
"note":"",
"role":"",
"area":""
},
{
"fullName":"Betty Ganot",
"address":"Modiin",
"phoneNumber":"054-3213211",
"email":"",
"note":"",
"role":"",
"area":""
},
{
"fullName":"Someone Else",
"address":"Somewhere",
"phoneNumber":"123456789",
"email":"",
"note":"",
"role":"",
"area":""
}
]';
//$json = file_get_contents('Test.txt');
$data = json_decode($json,true);
echo $data[0]['fullName'];
?>
Result: Shachar Ganot
When I run this code, its empty:
<?php
$json = file_get_contents('Test.txt');
$data = json_decode($json,true);
echo $data[0]['fullName'];
?>
Result: ****Empty - Nothig appears****
when I run this code, to check if file_get_contents is working:
<?php
$json = file_get_contents('Test.txt');
$data = json_decode($json,true);
echo $json;
?>
Result:
[ { "fullName":"Shachar Ganot", "address":"Yad Rambam", "phoneNumber":"050-1231233", "email":"", "note":"", "role":"", "area":"" }, { "fullName":"Betty Ganot", "address":"Modiin", "phoneNumber":"054-3213211", "email":"", "note":"", "role":"", "area":"" }, { "fullName":"Someone Else", "address":"Somewhere", "phoneNumber":"123456789", "email":"", "note":"", "role":"", "area":"" } ]
What I'm missing??
Needless to say I did JSON Valid with https://jsonformatter.curiousconcept.com/