I'm trying to show the top voters of the month on my website but I'm having trouble with this array:
{
"name":"Server name",
"address":"***********",
"port":"****",
"month":"201601",
"voters":[
{
"nickname":"John",
"votes":"6"
},
{
"nickname":"Beth",
"votes":"4"
},
{
"nickname":"Jimmy",
"votes":"4"
}
]
}
This is what I have but it's not working:
foreach($results as $nickname => $votes) {
$i++;
echo $i . '. ' . $nickname . ' (' . $votes . ')<br \>';
}
How would I go by doing this so it shows up like this?
- John (6)
- Beth (4)
- Jimmy (4)
Thank you.
Update: Wow, thank you guys! You were all extremely helpful. It was hard to choose an answer between them all. You're all awesome!
foreach($results['voters'] as $voter) {echo $voter['nickname'] . '(' . $voter['votes'] . ')'?results? Have youvar_dumped them?var_dump($results)and follow the bracketing...$resultshold?