How to create a multidimensional array

Well actually it’s a bit more involved than that.

I have a series of strings which are a comma delimitered sequence of integers… I want to use those strings to create a multi dimensional array. My difficulty that the sequence of numbers are of different lengths. perhaps it’s easier to visualize with an example:

I have the following strings coming from a DB:

0
0,1
0,2
0,3
0,4
0,4,7
0,4,8
0,4,9
0,4,9,14
0,4,9,17
0,3,5
0,3,10
0,3,10,12
0,3,10,13
0,3,10,15

so lets say the string comes along like:0,3,10,15
I want to be able to do something like: $CN[0][3][10][15]=“some name”
or if the string is: 0,3 then I could do $CN[0][3]=“Some name”

I suppose the easy part is to explode the string to make they keys… but how do i construct a function that creates varied depth multidimensional arrays? Preferably w/o using EVAL

Are there any replicates? eg.
1,2,3,4
1,2,3,4

If not you could simply explode and populate on the fly no?

Or maybe (MySQL?) a way to use LIKE - NOT LIKE % _ in a series of SELECTS?