Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
// https://twitter.com/codebyjeff/status/1057057070460022784
$array1 = ['col1' => 2, 'col2' => 5];
$array2 = ['col1' => 4, 'col2' => 1];
$array_total = collect($array1)->zip($array2)
->map->sum();
var_dump($array_total->all());
// [0 => 6, 1 => 6]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment