My Array is as below.
Array
(
[data] => Array
(
[28] => Array
(
[0] => 201
[1] => 202
)
[29] => Array
(
[0] => 301
[1] => 302
)
[30] => Array
(
[0] => 401
[1] => 402
)
)
)
I want to convert this array as below.
myarray = Array
(
[0] => Array
(
[data1] => 28
[data2] => Array
(
[0] => 201
[1] => 202
)
)
[1] => Array
(
[data1] => 29
[data2] => Array
(
[0] => 301
[1] => 302
)
)
[2] => Array
(
[data1] => 30
[data2] => Array
(
[0] => 401
[1] => 402
)
)
)
After converting the array as above, I am about to insert data1 and data2 values into database. Where I will loop like
for($i=0;$i<count($myarray);$i++)
{
$year = $myarray[$i]['data1'];
for($j=0;$j<count($myarray[$i][data2]);$j++)
{
insert($year,$myarray[$i][data2][$j]);
}
}
How can I do this? Please help me. Is this proper method in for loop where insert data into nested for loop. If our data array in too big like 10000 array counts for ($i) and 1000 counts for ($j), will it create problem for the insert function?
Any other proper conversion of array is also good for me. I just want to insert values like 201,202 with 28 and 301,302 with 29 into database.
Thank you.