aboutsummaryrefslogtreecommitdiff
path: root/challenge-088/henry-wong/php/ch-1.php
blob: 202052ca76be60592404c47f8fdd9d1497a28a80 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<?php
/**
TASK #1 › Array of Product
**/

function solution($a) {
  $b = array();
  for ($i = 0; $i < count($a); $i++) {
      $c = $a;
      unset($c[$i]);
      $b[] = array_product($c);
  }
  return $b;
}

$a = array(5, 2, 1, 4, 3);
print_r(solution($a));