Home > php教程 > php手册 > PHP: Parse JSON array

PHP: Parse JSON array

WBOY
Release: 2016-07-09 09:09:17
Original
873 people have browsed it
<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>?>
Copy after login
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template