Home >Backend Development >PHP Tutorial >PHP多个变量怎么组成一个变量

PHP多个变量怎么组成一个变量

WBOY
WBOYOriginal
2016-06-13 12:17:471749browse

PHP多个变量如何组成一个变量?
$xx['d1'][2]='你好!';

$a='xx';
$b='1';


我试过以下的写法,不对。
echo ${$a.'["d'.$b.'"][1]'};


求教如何组成一个变量作为输出?
------解决思路----------------------

<br />$xx['d1'][2]='你好!';<br /><br />$a='xx';<br />$b='1';<br /><br />echo ${$a}['d'.$b][2];<br />


是这样个意思么?
------解决思路----------------------
<br />    $array = array(1=>'a', 2=>'b');<br />    $name = 'array';<br />    $key = 1;<br />    echo ${$name}[$key];<br />

------解决思路----------------------
echo ${$a}['d'.$b][1];
------解决思路----------------------
<br />$xx['d1'][2]='abc';<br /><br />$a='xx';<br />$b='1';<br /><br />echo ${$a}['d'.$b][2];<br />

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