Имеется массив на входе:
Array
(
[project_id] => 4
[user_id_1190647361] => 1190647361
[user_id_1977462916] => 1977462916
[user_id_169505052] => 169505052
[user_id_622870866] => 622870866
[user_id_1436905292] => 1436905292
[user_id_2720806559] => 2720806559
)
Требуется перебрать массив и привести к требуемому виду:
Array
(
[0] => Array
(
[project_id] => 4
[user_id] => 1190647361
)
[1] => Array
(
[project_id] => 4
[user_id] => 1977462916
)
[2] => Array
(
[project_id] => 4
[user_id] => 169505052
)
[3] => Array
(
[project_id] => 4
[user_id] => 622870866
)
[4] => Array
(
[project_id] => 4
[user_id] => 1436905292
)
[5] => Array
(
[project_id] => 4
[user_id] => 2720806559
)
)
Помогите пожалуйста, затык случился, уже час туплю.
Пишу так:
$i = 0;
foreach ($post_data as $key => $item)
{
if ($key === 'project_id')
{
$data[$i][$key] = $item;
} else
{
$data[$i]['user_id'] = $item;
}
$i++;
}