我在while循环动态创建一些变量名:创建变量名动态
while($count < $agendaItemsCount) {
$tr_mcs_agendaitem_[$count]_1 = get_post_meta($post->ID, '_tr_mcs_agendaitem_' . $count . '_1', true);
++ $count
}
但是这个代码是造成意外的字符串解析错误。我该如何编写这段代码,以便通过count变量输出和var名称的其余部分声明新的var?
有什么好的理由不使用一个键值对数组? – Incognito 2012-02-20 14:01:14
[PHP变量变量]的可能重复(http://stackoverflow.com/questions/4511948/php-variable-variables) – jprofitt 2012-02-20 14:03:14
@Incognito我没有控制数据回来......我在wordpress工作。大括号不起作用.... $ tr_agendaitem _ {$ count} _1 = get_post_meta($ post-> ID,'agendaitem_'。$ count。'_1',true);仍然会产生语法错误 – 2012-02-20 14:09:28