There is an array with numbers Array ([0] => 11 [1] => 11 [2] => 11 [3] => 11 [4] => 24 [5] => 23 [6] => 24 [7 ] => 24 [8] => 23 [9] => 24 ...
)
It is necessary to replace '24' => '10', '11' => '6', '23' => '1' to summarize and output the result.
1 answer
It looks like a training task or social security. = /
$arr = array ( 0 => 11, 1 => 11, 2 => 11, 3 => 11, 4 => 24, 5 => 23, 6 => 24, 7 => 24, 8 => 23, 9 => 24); $replaces = array(24=>10,11=>6,23=>1); foreach($arr as &$value){ if(isset($replaces[$value])){ $value = $replaces[$value]; } } print(array_sum($arr)); - Interview in jun-jun-junior? - etki
- oneNo, September 1 has already come. If you know what I mean. - knes
- oneThis is a duplicate;) - Deonis
|