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

php取出json值?

WBOY
Release: 2016-06-06 20:19:17
Original
2375 people have browsed it

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

2.把json转成数组

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

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

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

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

Related labels:
php
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