hello i just want to ask if how to echo value/details using this API link that have given - http://themesnmotifs.com/api/wp/f6f60a0e7091a627641f01b9d1dd7536ea4b8496/list_wp - for example i want to echo all the companyand wp_cellphone -- .
thank you
hello i just want to ask if how to echo value/details using this API link that have given - http://themesnmotifs.com/api/wp/f6f60a0e7091a627641f01b9d1dd7536ea4b8496/list_wp - for example i want to echo all the companyand wp_cellphone -- .
thank you
That looks like JSON to me.
You can convert it to a PHP object using the json_decode() function.
$api = file_get_contents('http://themesnmotifs.com/api/wp/f6f60a0e7091a627641f01b9d1dd7536ea4b8496/list_wp');
$api_object = json_decode($api);
Hello ma'am thank you , after converting it , can i use the echo function()
to echo the details for example:
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
while($row = mysqli_fetch_array($result))
{
echo $row['Company'] . " " . $row['wp_phone'];
echo "<br>";
}
mysqli_close($con);
?>
In that example, you're fetching from a MySQLi resource (database).
Instead you would do this
$api = file_get_contents('http://themesnmotifs.com/api/wp/f6f60a0e7091a627641f01b9d1dd7536ea4b8496/list_wp');
$api_object = json_decode($api, true);
foreach ($api_object AS $row)
{
echo $row['Company'] . " " . $row['wp_phone'];
echo "<br>";
}
Thank you Ma'am Dani :)
PHP langauage is an advance and useful for web development and spread wide
Dear Dani maam,
Do you Please give a cURL version of GET Verb REST call instead of the file_get_contents() method ? Waiting your reply
Thanks,
Anes
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.