Home >Backend Development >PHP Tutorial >php取出json值?

php取出json值?

WBOY
WBOYOriginal
2016-06-06 20:19:172357browse

"order":{"result": "true", "arrive": "true", "first_fee": "12.00", "continue_fee": "8.00",…}

我想把order去掉 取出里面的值 我该怎么办?

回复内容:

"order":{"result": "true", "arrive": "true", "first_fee": "12.00", "continue_fee": "8.00",…}

我想把order去掉 取出里面的值 我该怎么办?

1.麻烦的办法

<code>使用正则匹配,极其不建议
</code>

2.把json转成数组

<code>$array = json_decode($json_str, true);</code>

这样子,这样就好看很多啦~

<code>$new_json_str = json_encode($array['order']);</code>

这样 $new_json_str 即是去掉order之后的新json串了。

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