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

PHP 获取数组里面值

WBOY
WBOYOriginal
2016-06-23 14:27:18956browse

php CodeIgniter 


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


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

回复讨论(解决方案)

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

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

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




版主太牛X

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