Bonjour,
J'ai réussit a faire ce que je voulais faire, a savoir extraire les champs "allow_embed", "country", "views_total", mais je me demandé si il n'y avait pas plus simple ?
Et aussi un meilheur contrôle des données ?
voici le code source :
Voici le résultat:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 <?php $myTweets = '{"page":1,"limit":2,"has_more":true,"list":[{"allow_embed":true,"country":"FR","views_total":7069},{"allow_embed":true,"country":"FR","views_total":4996}]}'; $myJSONTweets = json_decode($myTweets,TRUE); var_dump($myJSONTweets); foreach ($myJSONTweets as $t){ if(is_array($t)){ var_dump($t); for($i=0;$i<count($t);$i++){ echo "allow_embed: ".$t[$i]['allow_embed']."<br>"; echo "country: ".$t[$i]['country']."<br>"; echo "views_total: ".$t[$i]['views_total']."<br>"; } } } ?>
merci beaucoup
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35 array 'page' => int 1 'limit' => int 2 'has_more' => boolean true 'list' => array 0 => array 'allow_embed' => boolean true 'country' => string 'FR' (length=2) 'views_total' => int 7069 1 => array 'allow_embed' => boolean true 'country' => string 'FR' (length=2) 'views_total' => int 4996 array 0 => array 'allow_embed' => boolean true 'country' => string 'FR' (length=2) 'views_total' => int 7069 1 => array 'allow_embed' => boolean true 'country' => string 'FR' (length=2) 'views_total' => int 4996 allow_embed: 1 country: FR views_total: 7069 allow_embed: 1 country: FR views_total: 4996
Partager