在我的codeigniter
项目中,我试图在 Excel 中导出报告。在这里,我想通过比较2个数组值来打印值。
在array-1代码中:
$get_head_branch = $this->reports_model->getAllBranch();
foreach($get_head_branch as $branch)
{
$all_branchs[] = $branch['branchName'];
}
这是array-1的输出
Array
(
[0] => BVI
[1] => KLM
[2] => BSB
[3] => PPM
[4] => BRB
[5] => AGR
[6] => AYR
[7] => NMK
[8] => RPM
[9] => TCE
[10] => MAIN
[11] => PDI
[12] => SCR
[13] => SNR
[14] => SRT
[15] => SSC
[16] => VPM
[17] => ATR
[18] => GUI
)
在array-2代码中:
$getQuestionDivision = $this->reports_model->getQuestionDivision();
foreach($getQuestionDivision as $question_division)
{
$question_division1[] = $question_division['question'];
}
这是array-2的输出
Array
(
[0] => hp[p];lh;> ghh;l; ilk; Nehl;L ftdpg;gJ.
[1] => rpf;fdk; Nehl;L ftdpg;gJ.
[2] => ,ju gzp Nehl;L ftdpg;gJ.
[3] => \l;lh; Nehl;L ftdpg;gJ.
[4] => EB hPbq; Nehl;L ftdpg;gJ.
[5] => nk]; gFjp nghUs; nfhLf;Fk; Nehl;L ftdpg;gJ.
[6] => fha;fdp / /Gl;Nfhh;l; / ];tPl; Nt];l; Nehl;L ftdpg;gJ.
[7] => fha;fdp tpw;gid Fwpg;G Nehl;L ftdpg;gJ.
[8] => /Gl;Nfhh;l; tpw;gid Fwpg;G Nehl;L ftdpg;gJ.
[9] => kspif ];lhf; ftdpg;gJ.
[10] => mhprp ];lhf; ftdpg;gJ.
[11] => Mapy; ];lhf; ftdpg;gJ.
[12] => l;iuG&l;]; ];lhf; ftdpg;gJ.
[13] => ];tPl; & Ngf;fhp ];lhf; ftdpg;gJ.
[14] => gh;rdy; Nfh; ];lhf; ftdpg;gJ.
[15] => Fairbeat ];lhf; ftdpg;gJ.
[16] => gh;/g;A+k;> ghb ];gpNu ];lhf; ftdpg;gJ.
[17] => fthpq; ];lhf; ftdpg;gJ.
[18] => n[d;];Nth; ];lhf; ftdpg;gJ.
[19] => ngy;l; & gh;]; ];lhf; ftdpg;gJ.
[20] => Ngf; & #l;Nf]; ];lhf; ftdpg;gJ.
[21] => vth;rpy;th; ];lhf; ftdpg;gJ.
[22] => fpr;rd;Nth; ];lhf; ftdpg;gJ.
[23] => fpuhf;fhp ];lhf; ftdpg;gJ.
[24] => EB hPbq; Nehl;L ftdpg;gJ.
[25] => gpsh];bf; ];lhf; ftdpg;gJ.
[26] => vyf;l;uhdpf; ];lhf; ftdpg;gJ.
[27] => nry;Nghd; mf;rrhP]; ];lhf; ftdpg;gJ.
[28] => N`hk; mg;isad;]; ];lhf; ftdpg;gJ.
[29] => ];Nlrdhp ];lhf; ftdpg;gJ.
[30] => Nkl; ];lhf; ftdpg;gJ.
)
这是我的最终数组,我的意思是array-3代码
foreach($results as $main)
{
$excel1[] = array(
'question' => $main['question'],
'branch_name' => $main['branchName'],
'answer' => $main['answer'],
'divisionName' => $main['divisionName']*emphasized text*
);
}
array-3的输出
Array
(
[0] => Array
(
[branchName] => BVI
[question] => gpy;gb tUk;nghUs; nrf; nra;tJ.
[answer] => 1
[divisionName] => Sales/Admin
)
[1] => Array
(
[branchName] => BVI
[question] => gpy;gb tUk;nghUs; nrf; nra;tJ.
[answer] => 1
[divisionName] => Sales/Admin
)
[2] => Array
(
[branchName] => BVI
[question] => tUk;nghUs; thfd eilKiw Nehl;L ftdpg;gJ.
[answer] => 1
[divisionName] => Sales/Admin
)
[3] => Array
(
[branchName] => BVI
[question] => tUk;nghUs; thfd eilKiw Nehl;L ftdpg;gJ.
[answer] => 1
[divisionName] => Sales/Admin
)
[4] => Array
(
[branchName] => BVI
[question] => nghUs; ,wf;Fk;NghJ thfdk; mUfpy; epd;W ftdpg;gJ.
[answer] => 0
[divisionName] => Sales/Admin
)
[5] => Array
(
[branchName] => BVI
[question] => nghUs; ,wf;Fk;NghJ thfdk; mUfpy; epd;W ftdpg;gJ.
[answer] => 0
[divisionName] => Sales/Admin
)
)
现在这是我的查询,我想打印$excel1->answer
来比较array-1
和array-2
。
例如
array-1
问题值为hp[p];lh;> ghh;l; ilk; Nehl;L ftdpg;gJ.
array-2
branch_name的值为BVI
所以像这样打印