S.M_Emamian S.M_Emamian - 1 year ago 72
JSON Question

How to get json value of input form in codeigniter

I have a

variable and I want to post it as a

$json_value = json_encode($my_array);
echo '<input name="myvalue" type="hidden" value="'.$json_value.'" />';

in my function :

$posts = $this->input->post();
echo $posts['myvalue'];

but it is empty .

works correctly as I can fetch other values of inputs .

Answer Source

Change Your input to use single quotes inside

echo "<input name='myvalue' type='hidden' value='$json_value'  />";

since you are using double quotes inside and $json_value also has double quotes so there is a conflict.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download