2016-07-06 46 views
-1

我試圖環數據庫例程,但我有問題作出的獲取數組包含variable.g麻煩與製作獲取數組包含變量

${"db" . $currentTime . "11"} = ${"data" . $currentTime . "1"}[${$currentTLower . "11"}]; 

$currentTime包含「A」

$currentTLower包含'A'

所以行代碼是這樣的:

$dbA11 = $dataA1[a11]; 

但是,它並沒有辦法。

回答

1

你非常接近。指數應該是「A11」,但不是$a11在你的代碼

$currentTime = 'A'; 
$currentTLower ='a'; 
$dataA1['a11'] = 'value'; 

${"db" . $currentTime . "11"} = ${"data" . $currentTime . "1"}[$currentTLower . "11"]; 

echo $dbA11; // value 
+0

非常感謝您! –

+0

不客氣 – splash58

0
<?php 
$currentTime = "A"; 
$currentTLower = "A1"; 
$A111 = "Test"; 
$dataA1[$A111] = "This is content"; 
${"db".$currentTime."11"} = ${"data".$currentTime . "1"}[${$currentTLower . "11"}]; 
echo ${"db".$currentTime."11"}; 

// IT will print : This is content 
?>