I am not sure how to approach this, I need some advice on inserting data from a list of names. This is statistical type of data. Say I have an array that looks like this.
$basketball = array (
'teams' => array (
'orange' => array (
'names' => array(
'matt' => array('number' => '12', 'position' => 'guard'),
'john' => array('number' => '23', 'position' => 'forward'),
),
),
'blue' => array (
'names' => array(
'luke' => array('number' => '34', 'position' => 'guard'),
'brian' => array('number' => '45', 'position' => 'forward'),
),
),
),
);
Then inside my app I run a foreach on the names like this.
<?php foreach($basketball as $key => $teams): ?>
<?php foreach($teams as $team => $names): ?>
<div class="teams <?php echo $team ?>" data-score="0">
<?php foreach($names as $key => $players): ?>
<?php foreach($players as $player => $player_info): ?>
<div class="home-stats stats <?php echo $team ?>" data-player="<?php echo $player ?>">
<ul>
<li class="name">
<span><?php echo $player ?></span>
<input type="hidden" name="home-playername" value="<?php echo $player ?>" />
</li>
<li class="points">
<span>0</span>
<input type="hidden" name="home-points" value="0" />
</li>
</ul>
</div>
<?php endforeach; ?>
<?php endforeach; ?>
</div>
<?php endforeach; ?>
<?php endforeach; ?>
With this I am trying to figure out the best approach for adding the data, so that points matches the player, obviously I will have more stats and players but for the sake of example this is all I need.
I was thinking of using json
and rewriting the name attributes with jQuery and then building an array, and having a row for each team name, but again I can't think of how to rename these inputs to build a solid array, that looks like (sorry if Its a bit messed up but it's just an idea)
{"players":[{"matt":[{"stats":[{"points":"22"}]}],
"john":[{"stats":[{"points":"18"}]}]}]}
I guess this may be a pretty broad question, but summed up given the information if you were the developer how would you approach statistical style of data, the name of the player being the parent of all the information... OR... possibly the team name being the parent of all the information, either way once I figure the best approach I can go either way..