如何在ci中使用动态添加和删除时破坏textarea值?

this is my controller:

public function detail()
{
    if($this->input->post('submit'))
    {
        $a = $this->input->post('tutorial_overview');
        $tutorial_overview = implode(",",(array) $a);
        $data = array(
                        'tutorial_overview' => $tutorial_overview
                    );

        print_r($data)
    }
}

view: detail.php

<script>
    $(document).ready(function(){
        $("#btnAdd").click(function() {
            $("#add_ck").append('<div class="con"><label class="col-sm-3 control-label no-padding-right" for="form-field-1">Sub Heading Overview</label><div class="col-sm-7"><textarea id="overview" name="overview" class="col-xs-12"></textarea></div>' + '<input type="button" class="btnRemove" value="Remove"/></div>');
        });
        $('body').on('click','.btnRemove',function() {
            $(this).parent('div.con').remove()
        });
    });
</script>

<div class="form-group" id="add_ck">
    <label class="col-sm-3 control-label no-padding-right" for="form-field-1">Sub Heading Overview</label>
    <div class="col-sm-7">
        <textarea id="overview" name="overview" class="col-xs-12"></textarea>
    </div>
    <div class="col-sm-2">
        <input id="btnAdd" type="button" value="Add" />
    </div>
</div>

In this code I have a textarea where I have used add and remove more textarea through jquery. Now the problem is that when I am using implode function to seperate textarea value with comma (,) but now what happen when I click on add button and write something inside the text box and then print value it show me last textarea value implode fuction are not working. So, how can I fix this issue ?

Thank You

Hope this will help You :

Replace textarea name attr name="overview" with this name="overview[]", both in form and js code

And your controller method detail should be like this :

public function detail()
{
    if($this->input->post('submit'))
    {
        $a = $this->input->post('tutorial_overview');

        if ( ! empty($a))
        {
           foreach($a as $key => $item)
           {
              $data[$key]['tutorial_overview'] = $item;
           }
         }
        print_r($data)
    }
}