很久没有写过东西了,一个朋友问了我一个问题,简单整理整理,具体的数据我没有整理,简单的自己写了几个赋值
$wp1,$wp2,$wp3, $dr1, $dr2, $dr3,本身不是定义的是语言包里取的变量,我没有具体的项目用变量代替了
$wps = array();
$problems['washer'] = array('wp1' =>'b1' , 'wp2' =>'b2','wp3' =>'b3');
$problems['dryer'] = array('dr1' =>'B1' , 'dr2' =>'B2','dr3' =>'B3');
$wp1 = 'a1';
$wp2 = 'a2';
$wp3 = 'a3';
$dr1 = 'D1';
$dr2 = 'D2';
$dr3 = 'D3';
foreach($problems as $k=>$v){
foreach ($v as $kk => $vv) {
${$k}[$kk] = ${$kk};// 这个就是动态取语言包的值 $this->lang->line($kk);
}
$wps[$k] = ${$k};
}
$this->ajaxReturn(['status' => 1, 'result' => $wps]);
实现的效果