-
Notifications
You must be signed in to change notification settings - Fork 0
/
Share.php
33 lines (24 loc) · 817 Bytes
/
Share.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
class Share{
public static function sharePower(array $_numbers)
{
$min = min($_numbers);
//) recherche dans un tableau une valeur donnée et renvoie la clé.
$key = array_search($min, $_numbers);
unset($_numbers[$key]);
foreach($_numbers as $number){
//calcul 25 %
$powerToDelete = ( $number * 25 ) /100;
//ajout 25% pour le minimum
$tmpPowerToDel[] = $powerToDelete;
$newNumber[] = $number - $powerToDelete;
}
$totPowerToDel = array_sum($tmpPowerToDel);
$newMinValue = $totPowerToDel + $min;
var_dump($newNumber);
$finalNumber = array_push($totPowerToDel, $newNumber);
var_dump($newMinValue);
}
}
$number = [4, 1, 4];
Share::sharePower($number);