PHPExcel печатает значения, сравнивая 2 значения массива - PullRequest
0 голосов
/ 28 сентября 2018

В моем codeigniter проекте я пытаюсь экспортировать отчет в Excel .Здесь я хочу напечатать значения, сравнивая 2 значения массива.

Это мой лист Excel enter image description here

В коде массива-1:

$get_head_branch = $this->reports_model->getAllBranch();
foreach($get_head_branch as $branch)
{
   $all_branchs[] = $branch['branchName'];
}

Это вывод массива-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
)

В коде массива-2:

$getQuestionDivision = $this->reports_model->getQuestionDivision();
foreach($getQuestionDivision as $question_division)
{
    $question_division1[] = $question_division['question'];
}

Это вывод массива-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.
)

Это мой последний массив, я имею в виду код массива-3

foreach($results as $main)
{
    $excel1[] = array(
        'question' => $main['question'],
        'branch_name' => $main['branchName'],
        'answer'        => $main['answer'],
        'divisionName'  => $main['divisionName']*emphasized text*
    );
}

из массива-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 значение ветви_имя равно BVI

Таким образом, напечатайте вот так

enter image description here

...