Skip to content

Instantly share code, notes, and snippets.

@Rydgel
Created July 5, 2012 10:06
Show Gist options
  • Save Rydgel/3052756 to your computer and use it in GitHub Desktop.
Save Rydgel/3052756 to your computer and use it in GitHub Desktop.
<?php
$tournaments = [];
foreach($foos as $foo) {
$tournament["idTournament"] = $foo["idTournament"];
$tournament["name"] = $foo["name"];
$tournaments[] = $tournament;
unset($tournament);
}
json_encode($tournaments);
// will produce
[
{"idTournament": 13, "name": "kitchenette"},
{"idTournament": 14, "name": "salon"}
]
Côté objective-c en décodant le JSON ça te donnera un NSArray (dans le même ordre) de NSDictionary.
Donc si tu fais un objectAtIndex:0 ça te donnera un NSDictionnary contenant les clefs idTournament avec valeur 13 et name avec valeur kitchenette. etc.
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment