E
E
Evgeny Ivanov2018-02-07 08:00:11
PHP
Evgeny Ivanov, 2018-02-07 08:00:11

How to get value from json?

You need to get the status value.
But the value 236015091 is always different. How to do it?

$obj = json_decode($data);
echo $success=$obj->{"success"}; //Работает
//$status=$obj->{"return"}->{"xxxxxx???"}->{"status"}; //?????

{"success":1,"return":{"236015091":{"status":0,"pair":"rur_usd"}}}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maksim Fedorov, 2018-02-07
@Maksclub

<?php

$obj = json_decode($data, true);
$return = array_values($obj['return']); // Переиндексируем все значения в массиве 
var_dump($return[0]['status']); // Если элементов в JSON несколько, то можно циклом пройтись и достать все данные, сейчас достаю только у 1 элемента

https://ideone.com/tv2hI8

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question