2012-08-09 104 views
-1

如何Concat的数组索引值,如同我有两个变种如何在数组索引中连接两个变量? PHP

$string='helloworld'; 

$number=1

如何将我Concat的他们在阿雷值如$阵列[$串+ $数] = $值(一些值变量),但它给我导致像$阵列[1] =

$string="helloworld; 
    $number=1; 
    $array[$string+$number]=$value; 

结果,

$array[1]=... 

我尝试了所有方式使用,太多,但它不为你的建议

工作

希望

回答

3

+加号。 .连接字符串。

echo "Hello " . "world!"; 
0

Chaeck这一点

$string="helloworld"; // missing closing " 
$number=1; 
$array[$string . $number]=$value; // replace + with . for concatination 
0

合并上述两个答案...

$string="helloworld"; 
$number=1; 
$array[$string . $number]=$value;