3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = ['+5', '+5', '+3', '+3', '+3', '+3', '+5', '+5']; $total = 0; foreach (array_count_values($array) as $value => $count) { $total += $value * ($count - ($count > 1)); } echo $total;

preferences:
61.01 ms | 402 KiB | 5 Q