Home > Backend Development > PHP Tutorial > PHP 获取数组里面值

PHP 获取数组里面值

WBOY
Release: 2016-06-23 14:27:18
Original
955 people have browsed it

php CodeIgniter 


string(112) "{"code":"100","user":{"name":"张三"},"msg":"获取成功"}" 


PHP 怎么获取 数组里面的 user 括号里面name 值呢?

回复讨论(解决方案)

$s = '{"code":"100","user":{"name":"张三"},"msg":"获取成功"}';echo json_decode($s)->user->name; //张三
Copy after login
Copy after login

json_decode 后就是对象/数组了,之后就容易了吧。

$s = '{"code":"100","user":{"name":"张三"},"msg":"获取成功"}';echo json_decode($s)->user->name; //张三
Copy after login
Copy after login




版主太牛X

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