Have you ever wanted to calculate how much you will make weekly after taxes are taken out of each PayCheck?  I know that I did, and that’s why I made this script. The calculation/formula is pretty simple, so the script is as well.

How can a script like this be useful?

  • One can get a quick estimate of what they will make at a company.
  • Parse the potential salary of jobs sent too via email or that you got access to via an API. Then no time is wasted looking at jobs that don’t have a your desired pay.

Of course doing any of these things will require adding too the script. As this is a script to just help you get started. Maybe I will do a follow up post to this one showing how to display this. It will include the notes that I would use while I’m planning out writing the script.

PHP script to Calculate weekly pay after taxes!

// total-hours = 40 hours a week
// tax-rate = 16.5% 
// hourly-rate = 11.50;

// formula to calculate weekly pay
// total-hours * hourly-rate = weekly-pay
// weekly-pay * (tax-rate/100) = total-deducted
// weekly-pay - total-deducted = total-weekly-pay

$calculationInputs = array(
'total-hours' => 40, 
'tax-rate' => 16.5 / 100, 
'hourly-rate' => 11.50
);

// //the weekly pay before taxes. 
$calculationsResults = array('weekly-pay' => $calculationInputs['total-hours'] * $calculationInputs['hourly-rate'] );

// amount of taxes that will be deducted each week. 
$calculationsResults['total-deducted'] = $calculationInputs['tax-rate'] * $calculationsResults['weekly-pay'];

//total pay
$calculationsResults['total-weekly-pay'] = $calculationsResults['weekly-pay'] - $calculationsResults['total-deducted'];

//see the results 
//var_dump($calculationsResults);
Categories
PHP