Trying to learn JSON. Doing some simple exercises, but can't get past this one. I've rewatched the tutorial about 30 times. Any pointers?
here's the JSON:
{
"name": "Username",
"profile_name": "profile_username",
"profile_url": "http://myapi.net/profile_username"
"courses": [
{ "name": "English 340" },
{ "name": "History 202" },
{ "name": "Underwater Basket Weaving" }
]
}
It's in a variable called $JSON_array, and here's the foreach loop I'm trying to use to pull the course names out and put then in an unordered list.
<ul>
<?php for( $i = 0; $i < count($JSON_array->courses); $i++ ): ?>
echo '<li>';
echo $JSON_array->{'courses'}[$i]->{'name'};
echo '</li>';
<?php endfor; ?>
</ul>
Tis not doing anything... My source code shows empty list items
var_dump($JSON_array)forloop. useforeachwill work