php compare 2 array and manipulation increase value -
i have 2 array
a=array(a=>1,b=>2,c=>2,d=>2,e=>2,f=>2)
and
b=array(a,b,d)
i want make function compare_plus(array a, array b)
if array have key== array b val in increase value of array @ key 1.
example above array , b:
c=compare_plus(a,b) =>> c=(a=>2,b=>3,c=>2,d=>3,f=>2)
$a = array('a' => 1, 'b' => 2, 'c' => 2, 'd' => 2, 'e' => 2, 'f' => 2); $b = array('a', 'b', 'd'); $c = compare_plus($a, $b); print_r($c); function compare_plus($arr, $plusarr){ foreach($plusarr $key) $arr[$key]++; return $arr; }
Comments
Post a Comment