I need to loop through a bunch of arrays that I am getting back from mysql that contain a lot of duplicate entries and create one array out of several. The arrays will have one or more unique values in them so I need to keep these but some how concatenate them together into one string using commas or semicolons. So far I am not having any luck with this. Here is a phpfiddle
I need it to create a single array like this:
Array
(
[0] => Array
(
[0] => test
[1] => test
[2] => test
[3] => one
[4] => two
)
[1] => Array
(
[0] => test1
[1] => test
[2] => test
[3] => three
[4] => four
)
[2] => Array
(
[0] => test2
[1] => test
[2] => test
[3] => five, seven
[4] => six, eight
)
[3] => Array
(
[0] => test3
[1] => test
[2] => test
[3] => nine
[4] => ten
)
)
from an array like this
Array
(
[0] => Array
(
[0] => test
[1] => test
[2] => test
[3] => one
[4] => two
)
[1] => Array
(
[0] => test1
[1] => test
[2] => test
[3] => three
[4] => four
)
[2] => Array
(
[0] => test2
[1] => test
[2] => test
[3] => five
[4] => six
)
[3] => Array
(
[0] => test2
[1] => test
[2] => test
[3] => seven
[4] => eight
)
[4] => Array
(
[0] => test3
[1] => test
[2] => test
[3] => nine
[4] => ten
)
)
this is what I am trying:
for($i=0; $i < count($arrayBIG); $i++) {
if($arrayBIG[$i][0] == $arrayBIG[$i+1][0]) {
$clean[$i] = array(array_unique(array_merge($arrayBIG[$i],$arrayBIG[$i+1]), SORT_REGULAR));
}
}