[ create a new paste ] login | about

Link: http://codepad.org/aquc5DKA    [ raw code | output | fork ]

PHP, pasted on May 14:
1
2
3
4
5
6
7
8
9
10
11
12
13
<?php
$a = array('a' => 1, 'b' => 2, 'c' => 2, 'd' => 2, 'e' => 2, 'f' => 2);
$b = array('a', 'b', 'd', 'g', 'apple');

$c = compare_plus($a, $b);
print_r($c);

function compare_plus($arr, $plusarr){
    foreach($plusarr as $key)
        if (array_key_exists($key, $arr))
            $arr[$key]++;
    return $arr;
}


Output:
1
2
3
4
5
6
7
8
9
Array
(
    [a] => 2
    [b] => 3
    [c] => 2
    [d] => 3
    [e] => 2
    [f] => 2
)


Create a new paste based on this one


Comments: