Home > Backend Development > PHP Tutorial > php如何接收post方式的json并解析

php如何接收post方式的json并解析

WBOY
Release: 2016-06-23 13:09:31
Original
1671 people have browsed it

接收json的数据:{"location":"东钱湖"}
然后解析为 location=‘东钱湖’;
 


    json的数据如何解析?


回复讨论(解决方案)

json_decode

 知道用json_decode 来解析但是不知道怎么转换到location=‘东钱湖’;这种格式的。 

那就不知道你是怎么想的了

如果不是特定要求必须要转化成那种格式,只是要解析数据,那变成数组是最方便的

$s = '{"location":"东钱湖"}';print_r(json_decode($s, true));
Copy after login

Array
(
    [location] => 东钱湖
)

有key 有value. 
剩下就是拼了

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