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

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

WBOY
WBOYOriginal
2016-06-23 13:09:311651browse

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


    json的数据如何解析?


回复讨论(解决方案)

json_decode

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

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

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

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

Array
(
    [location] => 东钱湖
)

有key 有value. 
剩下就是拼了

Statement:
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