Codeigniter - 在单个mysql列中可能存在多维数组数据?

Multidimensional array data store inside a single mysql column.

Here it is my data. How to store it inside a single mysql column?

Someone tell me the solution with example code.

$data = array(
        '2017' => array(
            '6' => array(
                '10' => array(
                    'count' => 76
                ),
                '11' => array(
                    'count' => 42
                ),
                '15' => array(
                    'count' => 23
                ),
            ),
            '7' => array(
                '5' => array(
                    'count' => 26
                ),
                '25' => array(
                    'count' => 82
                ),
                '26' => array(
                    'count' => 53
                ),
            ),
        ),
        '2018' => array(
            '6' => array(
                '18' => array(
                    'count' => 30
                )
            )
        ),
    );

Have your column to type text for longer data. then use

$data = json_encode($data);

then store that $data.

Later, to get it. just use decode:

$data = json_decode($data); // Alternately json_decode($data,true);

You can serialize array to string for saving database also:

$stringData = serialize($data);

then you can unserialize back to array:

$data = unserialize($stringData );

serialize converts a PHP array or object to a string. unserialize converts that string into whatever it was stored as.