Dinesh Dinesh - 11 days ago 6
PHP Question

how to access object array as show in code

how to access each file name...

{"Appointments":
[
{
"file_name":"eeea4a560492004c5c14f9414e88c32c.jpg",
"file_type":"image\/jpeg",
"file_path":"C:\/inetpub\/wwwroot\/nautSearch\/server\/uploadedfiles\/files\/",
"orig_name":"a46cf6866df6f358bece629ef472ac69.jpg",
"file_ext":".jpg",
"file_size":418.17,
"is_image":true,
"image_width":2560,
"image_height":1440,
"image_type":"jpeg",
"image_size_str":"width=\"2560\" height=\"1440\""

},
{
"file_name":"c08ff85a44e0f86ab48ec709e6ba1b4a.jpg",
"file_type":"image\/jpeg",
"file_path":"C:\/inetpub\/wwwroot\/nautSearch\/server\/uploadedfiles\/files\/",
"file_ext":".jpg",
"file_size":27.38,
"is_image":true,
"image_width":479,
"image_height":403,
"image_type":"jpeg",
"image_size_str":"width=\"479\" height=\"403\""

},
{
"file_name":"4536acd0479c6c5dee3b1f546ed8d328.jpg",
"file_type":"image\/jpeg",
"file_path":"C:\/inetpub\/wwwroot\/nautSearch\/server\/uploadedfiles\/files\/",
"file_ext":".jpg",
"file_size":27.38,
"is_image":true,
"image_width":479,
"image_height":403,
"image_type":"jpeg",
"image_size_str":"width=\"479\" height=\"403\""

}
]
}

Answer

What you gave is a json string. First you must decode it and loop over the appointments to use the file names:

$result = json_decode($yourJsonString);

foreach ($result->Appointments as $appointment) {
    echo $appointment->file_name;
}
Comments