Home > Article > Backend Development > php handles json and xml
json transcoding
<code>json_encode(<span>$mixed</span>);</code>
json decoded into original data
<code>json_decode(<span>$json</span>,[ture]);<span>//ture</span> 表示解析成数组</code>
Judge whether the data is legal json string
<code><span><span>function</span><span>is_json</span><span>(<span>$string</span>)</span> {</span> json_decode(<span>$string</span>); <span>return</span> (json_last_error() == JSON_ERROR_NONE); }</code>
Copyright statement: Knowledge comes from the people, and is used by the people! Reprinting is welcome. Please attach a link to this article at the beginning. The article will be updated from time to time!
The above introduces how to process json and xml in PHP, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.