What’s the best way to multiply 2 arrays value by value in php? E.g $a1 = array(1, 2, 3); $a2 = array(2, 4, 6); Need $a3 to be (2, 8, 18). I was hoping for a shortcut without using a for(each) loop.
Thanks
[code=php] $keys = array_intersect_key($a1, $a2); foreach($keys as $ix) { $a3[$ix] = $a1[$ix] * $a2[$ix]; } [/code]
Help @Black_Knight spread the word by sharing this article on Twitter...