我正在尝试将来自 Wordpress 提要的数据与 Google Analytics API 数据合并,以创建一个包含每个帖子的页面浏览量的 Wordpress 帖子信息表。我想我可以匹配帖子网址来完成此操作,但我不确定如何执行此操作。我花了一些时间从两个来源获取数据,如下所示:
print_r($分析); 返回:
Array (
[0] => Array (
[url] => blog-post-url-121
[pageViews] => 34326 )
[1] => Array (
[url] => blog-post-url-245
[pageViews] => 14642 )
[2] => Array (
[url] => blog-post-url-782
[pageViews] => 13201 )
)
...我有将近 2,000 个实例
print_r($blogfeed); 返回
Array (
[0] => Array (
[url] => blog-post-url-457
[PostID] => 87249
[Date] => 2012-11-26 15:58:45
[Author] => John-Smith
[Title] => Blog Post Title #457
[Categories] => Dining, News )
[1] => Array (
[url] => blog-post-url-245
[PostID] => 88148
[Date] => 2012-11-26 15:00:20
[Author] => Mary-Jones
[Title] => Blog Post Title #245
[Categories] => Events, Nightlife )
)
我确信“关键”网址字段存在并且在博客提要和 Google Analytics API 数据中都匹配。所需的结果数组只需将“pageViews”数据添加到 $blogfeed 数组中的信息。所以
[1] => Array (
[url] => blog-post-url-245
[PostID] => 88148
[Date] => 2012-11-26 15:00:20
[Author] => Mary-Jones
[Title] => Blog Post Title #245
[Categories] => Events, Nightlife
[pageViews] => 14642 )
我尝试了 array_merge、array_merge_recursive 的不同变体,并在两个数组变量之间添加了一个“+”,但没有任何运气。
任何帮助将不胜感激。
谢谢!