Array ( [0] => Array ( [0] => "Product Category" [1] => Product Name [2] => Product ID [3] => Average Item Price [4] => Item Sales [5] => Items Sold [6] => Product Conversion (Sold/Views) [7] => Item Abandonment Rate ) [1] => Array ( [0] => OVERALL [1] => - [2] => - [3] => $51.17 [4] => $1335974.77 [5] => 26111 [6] => 16.25% [7] => 42.06% ) ARRAY B: Array ( [0] => Array ( [0] => "Content Category" [1] => Page Name [2] => Page Views [3] => Sessions [4] => Orders/Session [5] => Sales [6] => Bounce Rate [7] => Page Views/Session ) [1] => Array ( [0] => OVERALL [1] => - [2] => 1017924 [3] => 135154 [4] => 16.57% [5] => $1354866.20 [6] => 23.81% [7] => 7.53 )
我想两个数组合并成一个......在那里,结果将类似于:发现两个PHP数组匹配的元素,然后列出两个数组元素结合在一起
Array ( [0] => Array ( [0] => "Product Category" [1] => Product Name [2] => Product ID [3] => Average Item Price [4] => Item Sales [5] => Items Sold [6] => Product Conversion (Sold/Views) [7] => Item Abandonment Rate [8] => "Content Category" [9] => Page Name [10] => Page Views [11] => Sessions [12] => Orders/Session [13] => Sales [14] => Bounce Rate [15] => Page Views/Session ) [1] => Array ( [0] => OVERALL [1] => - [2] => - [3] => $51.17 [4] => $1335974.77 [5] => 26111 [6] => 16.25% [7] => 42.06% [8] => OVERALL [9] => - [10] => 1017924 [11] => 135154 [12] => 16.57% [13] => $1354866.20 [14] => 23.81% [15] => 7.53 )
我只想输出匹配的阵列,其中“产品类别”==“内容类别”,并结合这两个数组元素...
我不太确定是否有一个预定义的函数,但我假设我必须做一些array_intersect()或array_merge()...主要的一点是抓住匹配的元素和将来自两个阵列的两个元素合并为一个,以便我可以进行一些后期处理计算...
谢谢!
你尝试过什么? –
array_intersect($ arr1,$ arr2); 我得到了匹配的项目,但只显示第一个数组中的元素...我想结合这两个数组,但只显示“产品类别”/“内容类别”中的匹配项目,我需要项目从阵列A出售,并从阵列B的会话,所以我可以计算出售的项目/会议... – compleks