我有一个看起来像这样的数组
array(
[0] => array(
'id' => 1,
'title' => 'title 1',
),
[1] => array(
'id' => 10,
'title' => 'title 10',
),
[2] => array(
'id' => 11,
'title' => 'title 11',
),
[...]
);
我想向所有子数组添加一个元素。这与我添加的元素相同。所以新数组将如下所示:
array(
[0] => array(
'id' => 1,
'title' => 'title 1',
'type' => 'bag',
),
[1] => array(
'id' => 10,
'title' => 'title 10',
'type' => 'bag',
),
[2] => array(
'id' => 11,
'title' => 'title 11',
'type' => 'bag',
),
[...]
);
Is there a way to do it without iterating on the the first array?
It's gonna be a big array. I'm looking for the fastest way to do it.