I have an array that start with a specific index, always will be 43 the first index, after that I have info and I would like to split it into 2 after find the value products
but not always the value products
will be the index 64 it will be different everytime.
So I tried this to find the index where the value products is
$index = array_search('products', $data);
This way I can find the index where I would like to split the array in 2, but I have no idea how, I tried with array_chunk
but I couldn't make it work
This is my original array:
Array
(
[43] => 1234
[44] => 001
[45] => 100
[46] => 0
[47] => 0
[48] => 2
[49] =>
[50] => 1234
[51] => 001
[52] => 100
[53] => 0
[54] => 0
[55] => 2
[56] =>
[57] =>
[58] =>
[59] =>
[60] =>
[61] => 0
[62] => 1
[63] =>
[64] => products
[65] => 1234
[66] => 001
[67] => 100
[68] => 0
[69] => 0
[70] => 2
[71] =>
[72] => 1234
[73] => 001
[74] => 100
[75] => 0
[76] => 0
[77] => 2
[78] =>
[79] =>
[80] =>
[81] =>
[82] =>
[83] => 0
[84] => 1
)
And I would like something like this:
Array
(
[43] => 1234
[44] => 001
[45] => 100
[46] => 0
[47] => 0
[48] => 2
[49] =>
[50] => 1234
[51] => 001
[52] => 100
[53] => 0
[54] => 0
[55] => 2
[56] =>
[57] =>
[58] =>
[59] =>
[60] =>
[61] => 0
[62] => 1
[63] =>
)
Array
(
[65] => 1234
[66] => 001
[67] => 100
[68] => 0
[69] => 0
[70] => 2
[71] =>
[72] => 1234
[73] => 001
[74] => 100
[75] => 0
[76] => 0
[77] => 2
[78] =>
[79] =>
[80] =>
[81] =>
[82] =>
[83] => 0
[84] => 1
)
Also without the index of the value products
, do you have some idea what function can I use to achieve this or another way to do it? I hope you can help me, thank you.