php handles json and xml

WBOY
Release: 2016-07-29 09:15:27
Original
994 people have browsed it

json transcoding

<code>json_encode(<span>$mixed</span>);</code>
Copy after login

json decoded into original data

<code>json_decode(<span>$json</span>,[ture]);<span>//ture</span> 表示解析成数组</code>
Copy after login

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>
Copy after login

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.

Related labels:
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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!