Skip to content

Instantly share code, notes, and snippets.

@pinscript
Created July 21, 2012 20:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pinscript/3157106 to your computer and use it in GitHub Desktop.
Save pinscript/3157106 to your computer and use it in GitHub Desktop.
$players = array();
while($row = mysql_fetch_array($result))
{
extract($row);
$player = array (
'cbs_id' => $cbs_id,
'fname' => $fname,
'lname' => $lname,
'stats' => array()
);
$player['stats'][] = array(
'year' => $year,
'hr' => $hr,
'rbi' => $rbi
);
$players[] = $player;
}
$json = json_encode(array('players' => $players));
echo "<pre>$json</pre>";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment