我怎样才能使它提取递增变量直到它变空?

时间:2013-08-09 09:44:03

标签: php variables dynamic extract

extract ($wddx_0, EXTR_PREFIX_ALL, "wddx0");
extract ($wddx_1, EXTR_PREFIX_ALL, "wddx1");
extract ($wddx_2, EXTR_PREFIX_ALL, "wddx2");
extract ($wddx_3, EXTR_PREFIX_ALL, "wddx3");
extract ($wddx_4, EXTR_PREFIX_ALL, "wddx4");
extract ($wddx_5, EXTR_PREFIX_ALL, "wddx5");
extract ($wddx_6, EXTR_PREFIX_ALL, "wddx6");
extract ($wddx_7, EXTR_PREFIX_ALL, "wddx7");
extract ($wddx_8, EXTR_PREFIX_ALL, "wddx8");
extract ($wddx_9, EXTR_PREFIX_ALL, "wddx9");
extract ($wddx_10, EXTR_PREFIX_ALL, "wddx10");
extract ($wddx_11, EXTR_PREFIX_ALL, "wddx11");
extract ($wddx_12, EXTR_PREFIX_ALL, "wddx12");
extract ($wddx_13, EXTR_PREFIX_ALL, "wddx13");
extract ($wddx_14, EXTR_PREFIX_ALL, "wddx14");
extract ($wddx_15, EXTR_PREFIX_ALL, "wddx15");
extract ($wddx_16, EXTR_PREFIX_ALL, "wddx16");
extract ($wddx_17, EXTR_PREFIX_ALL, "wddx17");
extract ($wddx_18, EXTR_PREFIX_ALL, "wddx18");
extract ($wddx_19, EXTR_PREFIX_ALL, "wddx19");

这可以变为动态,这样它就会不断改变第一个和最后一个数字,直到它成为一个空变量,然后停止,并运行下一个函数?

1 个答案:

答案 0 :(得分:0)

for ($i=0; $i<=19; $i++){
    extract(${'wddx_'.$i}, EXTR_PREFIX_ALL, "wddx".$i);
}