如何将循环值从控制器传递到视图

时间:2017-01-07 02:03:55

标签: controller codeigniter-3

我想从控制器发布循环值到视图,下面是我的控制器。

<div class="col-sm-2 Column-VerticalLine">
<div></div>
<div style="font-weight: bold;"> Messeages </div>
<div style="font-weight: bold;"> Messeage Body bytes </div>
<div style="font-weight: bold;"> Process Memory </div>
</div>
<div class="col-sm-1 colum2">
<div style="font-weight: bold;"> Total </div>
<div> 0 </div>
    <div> 0B</div>
    <div> 21KB</div>
</div>

但是这段代码只显示数组的最后记录,如果我发布$ data来查看。

但如果这一行

public function sendEverything($soapinput) { $soap = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ben=\"http://xmlns.oracle.com/aaaa\"> <soapenv:Header/> <soapenv:Body> <ben:aaa>#aaa</ben:aaa> <ben:bbb>#bbb</ben:bbb> <ben:ccc>#ccc</ben:ccc> </soapenv:Body> </soapenv:Envelope>"; $soapexplode = explode("\r\n",$soapinput); for ($i=0;$i<count($soapexplode);$i++) { $loopvar = explode(',',$soapexplode[$i]); //var_dump($loopvar); $loopmsg = str_replace("#aaa",trim($loopvar['0']),$soap); $loopmsg = str_replace("#bbb",trim($loopvar['1']),$loopmsg); $loopmsg = str_replace("#ccc",trim($loopvar['2']),$loopmsg); //echo $loopvar[0]; $result = $this->nusoap_client->send($loopmsg,'process',30,30); if($this->nusoap_client->fault) { $text = 'Error: '.$this->nusoap_client->fault; echo $text; } else { if ($this->nusoap_client->getError()) { $text = 'Error: '.$this->nusoap_client->getError(); echo $text; } else { $data['msisdn'] = $loopvar[0]; $data['result'] = ($result['result'] === 0) ? 'Failed' : 'Success'; $this->load->view('content', 'soap/soapEverythingResult', $data); } } } }

我改变了这个

$this->load->view('content', 'soap/soapEverythingResult', $data);

它显示循环值,让输入3显示它将显示3个值。如下结果

echo "Result Status for send everything &nbsp;". $loopvar[0]."&nbsp; is &nbsp;". $data['result']. "<br>";

我的预期结果如上所述

0 个答案:

没有答案