Home >Backend Development >PHP Tutorial >在线等,把某个变量值当变量名怎么写?

在线等,把某个变量值当变量名怎么写?

WBOY
WBOYOriginal
2016-06-23 13:25:491202browse

$data是JSON,已经解码。
现在问题是$week的值为1,如何调用$data[0]->d13。其中d + $week的值 + '3'
怎么写??
我用$$好像不行呀。
求解!!


回复讨论(解决方案)

求解!!!

$data = json_decode('[{"d13":123}]');$week = 1;echo $data[0]->{'d'.$week.'3'};
123

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