B
B
bekozil2018-04-11 05:16:00
PHP
bekozil, 2018-04-11 05:16:00

How to output JSON data through PHP?

There is a link to JSON code
188.225.25.159:6734/api/diets
I get it this way:

$json = file_get_contents('http://188.225.25.159:6734/api/diets');
$obj = json_decode($json);

The var_dump shows. That's when I get an error UNDEFINED INDEX: TITLE Help, please. $obj["title"]

Answer the question

In order to leave comments, you need to log in

3 answer(s)
P
Pavel Kornilov, 2018-04-11
@KorniloFF

$arr = (array) json_decode ( file_get_contents('http://188.225.25.159:6734/api/diets'));

S
sundrey, 2018-04-11
@sundrey

$obj = json_decode($json, true );

F
frees2, 2018-04-27
@frees2

one

$json_data = $_POST['foo'];
$json = json_decode($json_data,true);

 
 $a = $json['name'];
 $b = $json['time'];
  $a2 = $json['name2'];

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question