Search the Community
Showing results for tags 'array_merge'.
-
I'm sure this is something simple that I'm just overlooking right now, but it's got me very frustrated and I just want a quick fix... I have 2 arrays, $data_old and $totals_old Let's say each looks like this (with the 123456 being different for both): Array ( [2014] => Array ( [123456] => Array ( [EMPS] => 114350 ) ) ) When I merge the two, I get something like this: Array ( [2014] => Array ( [0] => Array ( [123456] => Array ( [EMPS] => 114350 ) ) [1] => Array ( [60] => Array ( [EMPS] => 1470 ) ) ) ) How can I avoid the [0] and [1] and just have those be [123456] and [60], without referencing the 123456 and 60?
-
Hi phpfreak-ers, $BigArray[] = array('url' => 'www.example.com', 'referer' => 'refer1'); $BigArray[] = array('url' => 'www.demo.com', 'referer' => 'refer1'); $SmallArray[] = array('url' => 'www.example.com', 'referer' => 'refer2'); Basically I want to compare the two example arrays (above) and if a duplicate 'url' is found then I'd like to merge the 'referer' values in $BigArray otherwise add as an additional record. So I should be left with: Not syntax just used to explain my objective $BigArray url='www.example.com', 'referer' = 'refer1refer2'. $BigArray url='www.demo.com', 'referer' = 'refer1'. I've tried a day and a half worth of approaches and can't get it working. Thanks for your help in advance! Matt
- 7 replies
-
- array_unique
- array_merge
-
(and 1 more)
Tagged with: