-3

I have tried, checked many previous topics, and i cant find the way. Parsing JSON with PHP There is the answer, but im blind; actually, im a medimu PHP programmer, but im new with Json.

Here is my Json:

{"result":"true","disponible":{"aaa":"0.00001362","bbb":"0.000392","ccc":"0.00788523","ddd":"0.00004443","eee":"0.0001755","fff":"0.1755","ggg":"797.64618376"}}

My code:

$balances = json_encode(get_balances(),true);
print_r($balances);

The screen show my Json, so everything is ok here. Now, i want take the bolded values from the json and assign it to PHP variables.

$variable1 = $balances["disponible"]["bbb"];
$variable2 = $balances["disponible"]["ggg"];

echo "Valor 1: ".$variable1 ."<br>";
echo "Valor 2: ";$variable2 ;

But it dont work. I tried with many combinantions and nothing. What im doing wrong?

Thanks a lot in advance. Im blocked with this.

1 Answers1

0

Replace: $balances = json_encode(get_balances(),true); with: $balances = json_decode(get_balances(),true); if you are trying to get associative array.

iaforek
  • 2,860
  • 5
  • 40
  • 56