Insert values array to database by json_encode

I use codeigniter. i want insert to a row(residence) of database values array by json_encode, this is my html code(for example):

Demo: http://jsfiddle.net/AQPwv/3/

    <input name="name_r[0][]" value="hi">
    <p>
        <input name="units[1][]" value="how">
        <input type="text" name="units[1][]" value="2" style="width:20px;">
        <input type="text" name="units[1][]" value="256314" style="width:65px;">
        <input name="units[1][]" value="fine">
        <input type="text" name="units[1][]" value="4" style="width:20px;">
        <input type="text" name="units[1][]" value="854621" style="width:65px;">
        <p>
            <input type="text" name="price_change[2][]" value="21466" style="width:75px;">
            <input type="text" name="price_change[2][]" value="54219" style="width:75px;">
            <input type="text" name="price_change[2][]" value="48752" style="width:65px;">
            <input type="text" name="price_change[2][]" value="86541" style="width:75px;">
            <input type="text" name="price_change[2][]" value="47276" style="width:75px;">
            <input type="text" name="price_change[2][]" value="74538" style="width:65px;">
            <p>
                <hr>
    <p>
        <input name="name_r[0][]" value="hello">
        <p>
            <input name="units[1][]" value="Library">
            <input type="text" name="units[1][]" value="5" style="width:20px;">
            <input type="text" name="units[1][]" value="95641" style="width:65px;">
            <input name="units[1][]" value="khobee">
            <input type="text" name="units[1][]" value="6" style="width:20px;">
            <input type="text" name="units[1][]" value="84527" style="width:65px;">
            <input name="units[1][]" value="PowerTools ">
            <input type="text" name="units[1][]" value="7" style="width:20px;">
            <input type="text" name="units[1][]" value="75462" style="width:65px;">
            <p>
                <input type="text" name="price_change[2][]" value="8457" style="width:75px;">
                <input type="text" name="price_change[2][]" value="134" style="width:75px;">
                <input type="text" name="price_change[2][]" value="76144" style="width:65px;">
                <input type="text" name="price_change[2][]" value="956414" style="width:75px;">
                <input type="text" name="price_change[2][]" value="7546" style="width:75px;">
                <input type="text" name="price_change[2][]" value="123" style="width:65px;">
                <input type="text" name="price_change[2][]" value="84541" style="width:75px;">
                <input type="text" name="price_change[2][]" value="654" style="width:75px;">
                <input type="text" name="price_change[2][]" value="8165" style="width:65px;">
                <input type="text" name="price_change[2][]" value="2145" style="width:75px;">
                <input type="text" name="price_change[2][]" value="354" style="width:75px;">
                <input type="text" name="price_change[2][]" value="4774" style="width:65px;">

I done it by the PHP code, but it right does not work.
What is your proposal?

    $name_r_input = $this -> input -> post('name_r');
    $units_input = $this -> input -> post('units');
    $price_change_input = $this -> input -> post('price_change');
    $residence = array();
        foreach($name_r_input as $idx=>$name){
           $residence[] = array(
               'name_r' => $name_r_input[$idx],
               'units' => $units_input[$idx],
               'price_change' => $price_change_input[$idx],
            );
        };
    $data = array(
                'residence' => json_encode($residence),
            )
    $this->db->insert('table', $data);

A sample value in the database:

[{"name_r":["salam"],"units":null,"price_change":null},{"name_r":null,"units":["*&#8203;salam","khobe"],"price_change":null}]