I want to save string as an array in mongoDB database.
I get following string and I need to convert it to array for storing data in mongoDB database.
I am using codeigniter framework.
Input String
"[ [ 18, 18, 18, 18, 18, 18, 18, 18, 18 ], [ 2, 2, 2, 2, 2, 2, 2, 2, 2 ], [ 2, 2, 2, 2, 2, 2, 2, 2, 2 ], [ 2, 2, 2, 2, 2, 2, 2, 2, 2 ], [ 2, 2, 2, 2, 2, 2, 2, 2, 2 ], [ 2, 2, 2, 2, 2, 2, 2, 2, 2 ], [ 2, 2, 2, 2, 2, 2, 2, 2, 2 ], [ 2, 2, 2, 2, 2, 2, 2, 2, 2 ], [ 2, 2, 2, 2, 2, 2, 2, 2, 2 ] ]"
Desired Output
[
[
18,
18,
18,
18,
18,
18,
18,
18,
18
],
[
2,
2,
2,
2,
2,
2,
2,
2,
2
],
[
2,
2,
2,
2,
2,
2,
2,
2,
2
],
[
2,
2,
2,
2,
2,
2,
2,
2,
2
],
[
2,
2,
2,
2,
2,
2,
2,
2,
2
],
[
2,
2,
2,
2,
2,
2,
2,
2,
2
],
[
2,
2,
2,
2,
2,
2,
2,
2,
2
],
[
2,
2,
2,
2,
2,
2,
2,
2,
2
],
[
2,
2,
2,
2,
2,
2,
2,
2,
2
]
Thanks in advance.