Maison > php教程 > php手册 > le corps du texte

PHP 解析JSON数组

WBOY
Libérer: 2016-07-09 09:09:17
original
831 Les gens l'ont consulté
<span style="color: #000000;">php 

    </span><span style="color: #800080;">$postArray</span> ='[{"data":{"hello":"world"},"type":"1234","date":"2012-10-30 17:6:9","user":"000000000000000","time_stamp":1351587969902}, {"data":{"hello":"world"},"type":"1234","date":"2012-10-30 17:12:53","user":"000000000000000","time_stamp":1351588373519}]'<span style="color: #000000;">;
     
    
    </span><span style="color: #800080;">$de_json</span> = json_decode(<span style="color: #800080;">$postArray</span>,<span style="color: #0000ff;">TRUE</span><span style="color: #000000;">);
      </span><span style="color: #800080;">$count_json</span> = <span style="color: #008080;">count</span>(<span style="color: #800080;">$de_json</span><span style="color: #000000;">);
        </span><span style="color: #0000ff;">for</span> (<span style="color: #800080;">$i</span> = 0; <span style="color: #800080;">$i</span> $count_json; <span style="color: #800080;">$i</span>++<span style="color: #000000;">)
           {
                </span><span style="color: #008000;">//</span><span style="color: #008000;">echo var_dump($de_json);</span>
 
                  <span style="color: #800080;">$dt_record</span> = <span style="color: #800080;">$de_json</span>[<span style="color: #800080;">$i</span>]['date'<span style="color: #000000;">];
                   </span><span style="color: #800080;">$data_type</span> = <span style="color: #800080;">$de_json</span>[<span style="color: #800080;">$i</span>]['type'<span style="color: #000000;">];
                  </span><span style="color: #800080;">$imei</span> = <span style="color: #800080;">$de_json</span>[<span style="color: #800080;">$i</span>]['user'<span style="color: #000000;">];
                  </span><span style="color: #800080;">$message</span> = json_encode(<span style="color: #800080;">$de_json</span>[<span style="color: #800080;">$i</span>]['data'<span style="color: #000000;">]);

                }

</span>?>
Copier après la connexion
source:php.cn
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Recommandations populaires
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!