我正在使用YouTube API尝试将来自多个网址的JSON数据放入mySQL数据库。我正在尝试在多个JSON链接上使用json解码器,此刻我的代码删除了第一个数组并用第二个数据覆盖它。请注意,我不想使用array_merge函数,因为我想使用大约6-7个json URL。如果你可能非常具体,那也很棒,因为我对php很新。
$linkone = 'https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&maxResults=25&playlistId={playlistID}&key={Key}';
$linktwo = 'https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&maxResults=25&playlistId={PlaylistID}&key={Key}';
$content = file_get_contents($linkone);
$content2 = file_get_contents($linktwo);
$json = json_decode($content, true);
foreach($json['items'] as $row)
{
$title = $row['snippet']['title'];
$title = mysql_real_escape_string($title);
$description = $row['snippet']['description'];
$description = mysql_real_escape_string($description);
$publishedAt = $row['snippet']['publishedAt'];
$publishedAt = mysql_real_escape_string($publishedAt);
$high = $row['snippet']['thumbnails']['high']['url'];
$high = mysql_real_escape_string($high);
$sql = "INSERT INTO table(title, description, publishedAt, high) VALUES('".$title."','".$description."','".$publishedAt."','".$high."')";
if(!mysql_query($sql,$conn))
{
die('Error : ' . mysql_error());
}
}
答案 0 :(得分:0)
dfnew <- cbind(df1[, 1:2],
Count = lengths(lapply(pattern, grep, x = df2$query)))