php decode/aggregate remote JSON file

<?php $menuData = file_get_contents('http://www.sampleURL.com/file.json'); // put the contents of the file into a variable $menuItems = json_decode($menuData); // decode the JSON feed ?> <div class="main-menu"> <div class="list audio-menu"> <?php foreach ($menuItems as $menuItem) : ?> <div><?php echo $menuItem->link; ?></div> <div><?php echo $menuItem->title; ?></div> <?php endforeach; ?> </div> </div> /*Sample JSON File Structure*/ [ { "title":"Username One", "link":"URL One" }, { "title":"Username Two", "link":"URL Two" }, { "title":"Username Three", "link":"URL Three" } ]
Simple way to decode remote JSON data

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.