I need to merge associative arrays and group by the name. Say I have such 3 arrays:
ARRAY1
    "/path/file.jpg"  =>  2, 
    "/path/file2.bmp" =>  1,
    "/file3.gif"      => 5,
ARRAY2
    "/path/file.jpg"  =>  1, 
    "/path/file2.bmp" =>  1,
    "/file3.gif"      => 0,
ARRAY3
    "/path/file.jpg"  =>  1, 
    "/path/file2.bmp" =>  1,
I need to merge these arrays to one and group them by filepath and have result of sum of their values. Something like:
SELECT filename, SUM(val) FROM files
GROUP BY filename
But with multiple input arrays. Arrays are short (around 20 elements max). Each array might have different size.