J
J
JeAnonyme2018-08-19 00:51:03
PHP
JeAnonyme, 2018-08-19 00:51:03

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

3 answer(s)
S
SagePtr, 2018-08-19
@JeAnonyme

json_decode
And display - depending on what template engine you use there

I
ixon, 2018-08-19
@ixon

<?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
?>

D
devlocal, 2018-08-20
@devlocal

This is such a complicated question that it was necessary to ask about it here? And just open google and follow the first link that will be in the issue was weak? Or is it much more difficult and longer than writing here and waiting for answers.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question