我有两个数组。
例子:
array:4 [▼
0 => array:3 [▼
"title" => "News"
"created_at" => "2018-11-29 20:05:35"
"updated_at" => "2018-11-29 20:05:35"
]
]
array:2 [▼
0 => array:4 [▼
"title" => "News"
"created_at" => "2018-11-29 20:05:35"
"updated_at" => "2018-11-29 20:05:35"
"pivot" => array:2 [▶]
]
]
如何将in_array函数应用于此类数组? 我试图找到共同的价值观:
$tags=Tag::get(['title','created_at','updated_at'])->toArray();
dump($tags);
$newsTag=$new->tags();
$newsTag=$newsTag->get(['title','created_at','updated_at'])->toArray();
dump($newsTag);
foreach ($tags as $tag){
if(in_array($tag,$newsTag)){
echo $tag->name;
echo "1";
}
}