I’m attempting to load a comma-separated string of values from a database cell (e.g. 1,2,3,4,5,6,7,8,9,10,11,12) into a two-dimensional array.
There is another database cell containing a comma-separated string of table column headings, which dictate the number of sub-arrays within the main array.
So in the case of the example data above, I’d like the array to be something like this:
$data_table_array = array (
array(1,5,9),
array(2,6,10),
array(3,7,11),
array (4,8,12),
);
but to be able to automate this with a loop of some sort.
The data points populate a table with as many columns as column headings. I’ve got this working nicely but I decided that I wanted to give the user and option to add or delete columns as well as rows and editing the actual data. I believe that using this 2D array allows the flexibility to do this. – Or am I mistaken?
Sadly, I don’t know how to loop the data into the multidimensional array.
I have initially exploded the data into an array and I’m attempting to create a nested loop that will take me to the next stage. I wondered whether anyone out there could give me an example of a code structure that can achieve this?
I can provide further details of my problem but I didn’t want to confuse and complicate the issue too much.
I would very much appreciate it if someone can share their expertise with me for this very frustrating problem.
Many thanks in advance for your assistance.
Jason Green. N. London, UK