I have one array that I want to split into multiple arrays with array names and values based on the original array's elements. I am fetching the original array out of a database.
Let's call my original array "$myArray".
I could accomplish what I want by doing the following:
$col1[] = $myArray[col1];
$col2[] = $myArray[col2];
$col3[] = $myArray[col3];
$col4[] = $myArray[col4];
Later in the page I will access $col1[0] for a value.
I need the new array names to be based on the keys from the original array. My question is, can i do this with a loop somehow, dynamically creating the new array names based on original values? The reason being that I don't want to rely on hardcoding the new array names because there are a lot of them, and more importantly they may be changed elsewhere.
Is it possible somehow?