M
M
Maxim Plotnikov2019-11-03 23:16:14
PHP
Maxim Plotnikov, 2019-11-03 23:16:14

How to get correct data from JSON array?

Good day, I ran into one of the problems.
I receive a response from the server and something I can’t get the information I need from it.
Please help, below is the response from the server.

{ 
   "accounts":[ 
      { 
         "alias":"qw_wallet_rub",
         "fsAlias":"qb_wallet",
         "bankAlias":"QIWI",
         "title":"Qiwi Account",
         "type":{ 
            "id":"WALLET",
            "title":"Visa QIWI Wallet"
         },
         "hasBalance":true,
         "balance":{ 
            "amount":376.87,
            "currency":643
         },
         "currency":643,
         "defaultAccount":true
      }
   ]
}

Thanks in advance.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
O
Oleg Frolov, 2019-11-03
@Digiport

$result = json_decode($data,true);
get the data as an associated array

P
Pashenka, 2019-11-03
@like-a-boss

You are a programmer! What's the problem then?

$array = json_decode($response, true);
echo $array['accounts']['0']['alias']; // вот, к примеру, олеас

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question