Skip to content

Instantly share code, notes, and snippets.

@mralexgray
Forked from jaubourg/php-json-heredoc.php
Created February 18, 2012 01:29
Show Gist options
  • Save mralexgray/1856753 to your computer and use it in GitHub Desktop.
Save mralexgray/1856753 to your computer and use it in GitHub Desktop.
<?php
## Nav data, as a JSON heredoc. Much less verbose than PHP arrays!
$navs = json_decode(<<<JSON
{
"mlb": {
"title_link": "http://stats.boston.com/mlb/scoreboard.asp",
"nav": [
{ "title": "Full Schedule", "url": "http://stats.boston.com/mlb/teamreports.asp?tm=02&report=schedule" },
{ "title": "Statistics", "url": "http://stats.boston.com/mlb/teamreports.asp?yr=2009&tm=2&btnGo=Go&report=stats" },
{ "title": "Standings", "url": "http://stats.boston.com/mlb/standings.asp" }
]
},
"nfl": {
"title_link": "http://stats.boston.com/fb/scoreboard.asp",
"nav": [
{ "title": "Full Schedule", "url": "http://stats.boston.com/fb/teamstats.asp?yr=2009&tm=17&btnGo=Go&type=schedules" },
{ "title": "Statistics", "url": "http://stats.boston.com/fb/teamstats.asp?teamno=17&type=stats" },
{ "title": "Standings", "url": "http://stats.boston.com/fb/totalstandings.asp" },
{ "title": "Season timeline", "url": "http://timelines.boston.com/patriots" }
]
},
"nhl": {
"title_link": "http://stats.boston.com/nhl/scoreboard.asp",
"nav": [
{ "title": "Full Schedule", "url": "http://stats.boston.com/nhl/teamstats.asp?teamno=01&btnGo=Go&type=schedule" },
{ "title": "Statistics", "url": "http://stats.boston.com/nhl/teamstats.asp?teamno=01&btnGo=Go&type=stats" },
{ "title": "Standings", "url": "http://stats.boston.com/nhl/standings_conference.asp" },
{ "title": "Season timeline", "url": "http://timelines.boston.com/bruins#/seasons/2009" }
]
},
"nba": {
"title_link": "http://stats.boston.com/nba/scoreboard.asp",
"nav": [
{ "title": "Full Schedule", "url": "http://stats.boston.com/nba/teamstats.asp?teamno=02&btnGo=Go&type=schedule" },
{ "title": "Statistics", "url": "http://stats.boston.com/nba/teamstats.asp?teamno=02&btnGo=Go&type=totstats" },
{ "title": "Standings", "url": "http://stats.boston.com/nba/standings_conference.asp" },
{ "title": "Season timeline", "url": "http://timelines.boston.com/celtics" }
]
}
}
JSON
, true);
## Get nav data
$nav =& $navs[ $_GET['league'] ? strtolower( $_GET['league'] ) : 'all' ];
## Output.
?><div class="scorebelt">
<div class="scorebelt-nav">
<? if ( $nav['title_link'] ): ?>
<h3><a href="<?= $nav['title_link'] ?>">Scoreboard</a></h3>
<? else: ?>
<h3>Scoreboard</h3>
<? endif; ?>
<ul>
<? foreach ( $nav['nav'] as $item ): ?>
<li><a href="<?= $item['url'] ?>"><?= $item['title'] ?></a></li>
<? endforeach; ?>
</ul>
</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment