laravel在视图中传递2维数组

时间:2017-02-18 03:30:07

标签: php laravel-5.1

我想在视图视图中播放一个数组

控制器代码是

 $service = geoserver_url;
$data = "<workspace><name>testnew</name></workspace>";
        $url = $service . "rest/workspaces/workspacename";
        $ch = curl_init($url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        $passwordStr = username:password
        curl_setopt($ch, CURLOPT_USERPWD, $passwordStr);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-type: application/xml"););
          curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');   
            curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
        $result = curl_exec($ch);

        $info = curl_getinfo($ch);

    Any kind of help appreciated.

我无法在视图中使用每个

检索它
$data['medications'] = array('medicine' => 'meds',
                             'dosage' => 'dosage');

return view('medications.index', $data);

2 个答案:

答案 0 :(得分:0)

只需使用$data

即可
   @foreach($medications as $data)
         {{$data}}
    @endforeach

答案 1 :(得分:0)

你必须使用它。

@foreach($medications as $data)
         {{$data}}
    @endforeach

因为这里的$药物是你制作的数组 $ data ['medications'] = array('medicine'=&gt;'meds',                              '剂量'=&gt; '剂量');