# How can I create array of array contains characters with solidity

I recently approached the Smart contract two days ago. I'm still learning about it, and I have a lot of difficulties. Can you help me to create a variable like this photo?

It has a arrays of numbers from 1 to infinity. Each natural number has a array of characters. Each character has array of string, like ["abc","qwe"]

For example I have 2 functions:

• One for add data, like addString(uint number, uint character, string info)
• One for get data, like getString(uint number, uint character)

When I call addString(1,"a","abc"). It will create "a" if it does not already exist, after that it will put "abc" to array.

When I call addString(1,"a","qwe"). it will put "qwe" to array. Now the array of "a" like ["abc","qwe"]

When I call addString(1,"b","abc"). It will create "b" if it does not already exist, after that it will put "abc" to array. Now the array of "b" like ["abc"]

When I call getString(1, "a"), It will return ["abc","qwe"]

When I call getString(1, "b"), It will return ["abc"]

When I call getString(1, "c"), It will return []

This guy has problems almost like me. You can view this

Thanks for helping me

• I can see how to do this but I'm puzzled by the purpose of the natural number that is 1 in every example. Is this a hidden assumption about the implementation details or an important requirement? What if it was 0 or 2, or 99999? – Rob Hitchens Aug 25 '18 at 14:15
• @RobHitchensB9lab "It has a arrays of numbers from 1 to infinity. Each natural number has a array of characters. Each character has array of string, like ["abc","qwe"]" It's just an index into an array. (Think `mapping(uint256 => string[])[]`. The number is an index into the array.) – user19510 Aug 25 '18 at 15:26
• @Truong You'll run into trouble with `getString()`. Solidity currently doesn't support returning arrays of arrays. (A `string` is an array, so returning `string[]` won't work.) If you can limit all your strings to a maximum of 32 characters, a common trick is to use `bytes32` instead of `string`. – user19510 Aug 25 '18 at 15:27
• @RobHitchensB9lab It's just an index into an array. It start with index 1 not 0. Smarx, Can you tell me more clearly, I do not know what you mean. I have research about it, but do not know how to use it to solve this problem. – Truong Aug 25 '18 at 15:31
• @Truong Have you written any code yet? Please share what you've written so far and where specifically you got stuck. It's hard to know how to help without just writing the code for you. – user19510 Aug 25 '18 at 15:33