我正在使用while循環,我需要能夠將變量的值分配給新變量的名稱。這裏是環($ SLIDE_NUMBER總是返回數):如何在新變量名中使用變量?
$slide_number = theme_get_setting('slides_number');
$count = '1';
while ($count <= $slide_number) {
$slide_path = theme_get_setting('slide_path_'.$count.'');
if (file_uri_scheme($slide_path) == 'public') {
$slide_path = file_uri_target($slide_path);
}
$count++;
}
所以我們可以說$ SLIDE_NUMBER爲2。我需要產生$ slide_path_1和$ slide_path_2,讓我怎麼了$ count變量添加到$ slide_path創建$ slide_path_1和$ slide_path_2?
爲什麼不使用數組呢? – pmakholm
也許[variablevariables](http://php.net/manual/en/language.variables.variable.php)是你正在尋找的東西? – complex857
此問題已被提問並回答數百次...請在再次提問之前嘗試搜索功能:) – rdlowrey