コード
<?php
$array = [
['staff' => 'name1,name2,name3,name5'],
['staff' => 'name4,name5,name6,name1'],
];
$result = [];
foreach ($array as $value){
$result = array_merge($result,explode(',',$value['staff']));
}
$mergedArray = array_merge(...array_map(function($item) {
return explode(',', $item['staff']);
}, $array));
または
$res = array_merge(...array_map(function($v){return explode(',',$v['staff']);},$array));
$res = array_merge(...array_map(fn($v) => explode(',',$v['staff']),$array));
var_dump($res);
結果2
array(8) {
[0]=>
string(5) "name1"
[1]=>
string(5) "name2"
[2]=>
string(5) "name3"
[3]=>
string(5) "name5"
[4]=>
string(5) "name4"
[5]=>
string(5) "name5"
[6]=>
string(5) "name6"
[7]=>
string(5) "name1"
}