javascript - 需要在 CodeIgniter View 中以字符串格式显示一个值

标签 javascript php css codeigniter phpmyadmin

我正在尝试在 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/

相关文章:

php - 如何更改 mysql 和 php 中的表列?

css - iframe 大小以适合父 div

javascript - 如果复选框被选中,如何添加一个元素,如果没有被选中,如何删除它?

javascript - 在单个页面中引入多个加载器: React JS

javascript - NodeJS 创建 CSV 直接写入 Google Storage

PHP发送变量到其他页面

javascript - 为什么我不能删除这个对象的类/属性

php - PHPUnit 中的测试级别/组

Html 表格将列宽连接在一起

查询 :before and Css