2012-08-09 103 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;