Skip to content

Instantly share code, notes, and snippets.

@YurePereira
Created March 5, 2017 18:00
Show Gist options
  • Select an option

  • Save YurePereira/af8fb7d43ba63b19108f25e1edcb349f to your computer and use it in GitHub Desktop.

Select an option

Save YurePereira/af8fb7d43ba63b19108f25e1edcb349f to your computer and use it in GitHub Desktop.
Reajustes salárial usando a função array_map com mais de um array
<?php
//Lista de funcionários e seus correspondentes salários:
$listSalary = array(
'employee_1' => 2100.00,
'employee_2' => 2500.00,
'employee_3' => 3000.00,
'employee_4' => 1300.00,
'employee_5' => 2100.00,
);
$listReadjustmentValue = array(
'employee_1' => 10.0,
'employee_2' => 3.5,
'employee_3' => 5.0,
'employee_4' => 4.0,
'employee_5' => 3.0,
);
//Função para reajustes salárial:
function readjustSalary($valueSalary, $readjustmentValue) {
return $valueSalary + ($valueSalary * $readjustmentValue / 100);
}
$listSalary = array_map('readjustSalary', $listSalary, $listReadjustmentValue);
print_r($listSalary);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment