CodeIgniter将视图加载到数组中

I'm trying to load a view which contains html elements like div etc into an array, but I'm having trouble doing it. Somehow, even if I replace quotation marks, it seems to be causing error. After loading the view into the array

$tmp =  $this->load->view('details/action_task');
$result['html'] = str_replace('\\"','\\\\"', $tmp);

$resp = json_encode($result);

on chrome console, output is

{"code":1,"html":""}            
            <div class="text-center">Response</div>

As you can see html is empty, and its "should be" value is out of the json object. Any idea on solving this?

查看全部
doushuo2834
doushuo2834
2015/04/13 08:20
  • codeigniter
  • json
  • php
  • 点赞
  • 收藏
  • 回答
    私信
满意答案
查看全部

1个回复