【发布时间】:2020-11-18 15:37:53
【问题描述】:
比较两个数组后需要用标签更新帖子。如何在新数组中提取嵌套数组的“id”?
<pre>
//$post->tags->toArray()
array:2 [▼
0 => array:5 [▼
"id" => 1
"name" => "tag1"
"created_at" => "2020-07-27T17:36:28.000000Z"
"updated_at" => "2020-07-27T17:36:28.000000Z"
"pivot" => array:2 [▶]
]
1 => array:5 [▼
"id" => 2
"name" => "tag2"
"created_at" => "2020-07-27T17:36:30.000000Z"
"updated_at" => "2020-07-27T17:36:30.000000Z"
"pivot" => array:2 [▶]
]
]
//Result of $request->tags
array:3 [▼
0 => "1"
1 => "2"
2 => "3"
]
</pre>
【问题讨论】:
标签: arrays laravel collections