Answer the question
In order to leave comments, you need to log in
How to extract data from JSON in PHP?
We need to extract data from JSON and display using PHP and HTML. What is the best way to do this?
File with sample values:
{"apiVersion":"1.3", "data":
{"id":"2","username":"slovyanich","first_name":"","last_name":"","website":"","country":"Ukraine","city":"","address":"","image":"1831805871_1234263189_1081166798.jpg","cover":"1532897724_554195148_1974196412.jpg","verified":"0"}}
Answer the question
In order to leave comments, you need to log in
json_decode
And display - depending on what template engine you use there
<?php
$json = '{"id":"2","username":"slovyanich","first_name":"","last_name":"","website":"","country":"Ukraine","city":"","address":"","image":"1831805871_1234263189_1081166798.jpg","cover":"1532897724_554195148_1974196412.jpg","verified":"0"}';
$jsonDe = json_decode($json,true);
var_dump($jsonDe);//Именованный массив
echo $jsonDe["id"];//=>2
?>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question