标签:php
我有变量$CV1,$CV2,$CV3 …如何在PHP的while循环中获取这些变量的值?下面是我的代码
$CV1=$fetch->Custom_field1;
$CV2=$fetch->Custom_field2;
$CV3=$fetch->Custom_field3;
$CV4=$fetch->Custom_field4;
$query=mysql_query("select * from customfields where CustomField like '%Invoice%' and CustomLabel != ''");
while($get=mysql_fetch_object($query))
{
$i++;
$Label=$get->CustomLabel;
$CFV='$CV'.$i;
echo "
$Label";}
但不是获取$CV1的值,而是$CV2.我正在获取变量名称本身作为输出. $CV1,$CV2等
解决方法:
您可以使用:
$CFV = ${'CV'.$i};
标签:php
来源: https://codeday.me/bug/20191127/2075819.html