I am trying to display a value $raw
which is in an array format to a textbox in a CodeIgniter view
This is the function I am using in my controller:
public function pricing($raw='array')
{
if ($raw === 'array')
{
return $this->result_array();
}
}
I tried this but still getting message:array to string conversion
I am using $raw
in my view ‘add_calendar.php’:`
<?php echo(['name'=>'tohr','class'=>'form-control','placeholder'=>'Enter total hire rate','value'=>'$raw'])?>
2
Answers
Pass the array from the controller to view
$raw
is a variable don’t use single quotes'
for itView
You can use these values with or without HTML tags
Without HTML tags
With HTML tags
You can not echo an array because echo expects string as its parameter. Since you are trying to echo the values to a textbox you may want to do this.
When you load your view pass
$raw
to your view.Then in your view use
form_input
to create a textbox.