我正在尝试在 CodeIgniter View 中将数组格式的值 $raw
显示到文本框
这是我在 Controller 中使用的功能:
public function pricing($raw='array')
{
if ($raw === 'array')
{
return $this->result_array();
}
}
我试过了,但仍然得到 message:array to string conversion
我在 View 'add_calendar.php' 中使用 $raw
:`
<?php echo(['name'=>'tohr','class'=>'form-control','placeholder'=>'Enter total hire rate','value'=>'$raw'])?>
最佳答案
你不能回显一个数组,因为回显需要字符串作为它的参数。由于您正在尝试将值回显到文本框,因此您可能需要这样做。
当您加载 View 时,将 $raw
传递给您的 View 。
$data = array('raw'=>$raw);
$this->load->view('add_calendar', $data);
然后在您的 View 中使用 form_input
创建一个文本框。
echo form_input(['name'=>'tohr','class'=>'form-control','placeholder'=>'Enter total hire rate','value'=>$raw]);
关于javascript - 需要在 CodeIgniter View 中以字符串格式显示一个值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55999618/