Organizational Research By

Surprising Reserch Topic

php json decode how to output array using -'php,json'

php json decode how to output array  using -'php,json'

Here is my php code with json formatted string:


$string='{"items":  [
    "address":"W 7th Ave"
    "address":"W 8th St"

$json = json_decode($string, true);

    foreach ($json as $key => $value){
        echo "$key: $value\n";


I want to learn how to parse/output json string into something I can show in html or put into database .. however i am stuck on something that is prob very simple but I've spent most of the morning trying to figure out.

What I want to understand is why the results of my code above gives me the following result:

"items: Array"

And not what I want/expect to get:

"items: W 7th Ave"
"items: W 8th St"

What am i missing?  Isn't "Address" the next "level" down from "Item" in the array?

asked Sep 7, 2015 by rajesh
0 votes

Related Hot Questions

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.