Iam getting a json data from an API in the following format:
{"total":254,
"countries":[
{
"name":"Zimbabwe",
"code3":"ZWE",
"code":"ZW"
},
{
"name":"Zambia",
"code3":"ZMB",
"code":"ZM"
},
{
"name":"Yemen",
"code3":"YEM",
"code":"YE"
},
{
"name":"XO",
"code3":"XO ",
"code":"XO"
}
}
This is my PHP Script to access the API data:
<?php
$curl = curl_init();
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'api-key: 1234',
'Content-Type: application/json',
'Accept: application/json'
));
curl_setopt ($curl, CURLOPT_URL, 'https://api.com/api/v3/countries');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$xml = curl_exec ($curl);
if ($xml === false) {
die('Error fetching data: ' . curl_error($curl));
}
curl_close ($curl);
echo htmlspecialchars("$xml", ENT_QUOTES);
?>
How will i call the results in a table format or bootstrap format?