Of an API returns JSON data, it is basically returning a string.  That
string is a just a representation of the dictionary.  If you want to access
the data, you would use json_decode() to convert the string to a php object:

http://php.net/manual/en/function.json-decode.php

-John
 On Sep 2, 2014 1:32 AM, "Dan Egli" <[email protected]> wrote:

> Hey Pluggers, I need some quick reference help in PHP. Apparently I can't
> think how to compose the right Google query at the moment. I must need to
> practice my GoogleFoo more. :S
>
> I have a program that I'm writing in PHP. It needs to reference a 3rd party
> API. However, that API wants to return most of the values I'm looking as
> what I think are JSON dictionaries. This is something I've never dealt with
> (or even heard of) before. How in the heck do you access a part of a JSON
> dictionary? For example, given the following:
>
> var_dump($api->cur_bal());
> {'timestamp': '139396594', 'acct1': { 'available' : '12594.56', 'pending' :
> '415.4264' }, 'reserve' : { 'available' : '175.11' }}
>
> How would I access, for example, the value of 'pending' under 'acct1'? Or
> the 'available' under reserve?
>
> Any good web sites (specific URLs needed, please!) that could also explain
> what a JSON is and how it gets used would be greatly appreciated.
>
> Thanks folks!
> --- Dan
>
> /*
> PLUG: http://plug.org, #utah on irc.freenode.net
> Unsubscribe: http://plug.org/mailman/options/plug
> Don't fear the penguin.
> */
>

/*
PLUG: http://plug.org, #utah on irc.freenode.net
Unsubscribe: http://plug.org/mailman/options/plug
Don't fear the penguin.
*/

Reply via email to