'', 'amps' => '', 'watts' => '', 'ohms' => '' ); // Clear zeroes. The above makes empty fields =0. if ($in['volts'] == '0'){ $in['volts'] = ''; }else{ $out['volts'] = $in['volts']; }; if ($in['amps'] == '0'){ $in['amps'] = ''; }else{ $out['amps'] = $in['amps']; }; if ($in['watts'] == '0'){ $in['watts'] = ''; }else{ $out['watts'] = $in['watts']; }; if ($in['ohms'] == '0'){ $in['ohms'] = ''; }else{ $out['ohms'] = $in['ohms']; }; // Process through all possible options until something is found, or nothing. // Run this a few times, just in case. Overkill, but may be useful later. $count = 0; while ($count <= 3){ $count++; // ===== VOLTS ================================== if ($out['volts'] == ''){ if ( ($in['amps'] != '') && ($in['ohms']) ){ $out['volts'] = $in['amps'] * $in['ohms']; }; if ($debug == 1){ if ($out['volts'] != ''){ print "Conversion [V1] V=I x R : " . $out['volts'] . " = " . $in['amps'] . "*" . $in['ohms'] .";
"; }; }; }; if ($out['volts'] == ''){ if ( ($in['watts'] != '') && ($in['amps']) ){ $out['volts'] = $in['watts'] / $in['amps']; }; if ($debug == 1){ if ($out['volts'] != ''){ print "Conversion [V2] V=P/R : ".$out['volts']." = ".$in['watts']." / ".$in['amps'].";
"; }; } }; if ($out['volts'] == ''){ if ( ($in['watts'] != '') && ($in['ohms']) ){ $out['volts'] = sqrt($in['watts'] * $in['ohms']); }; if ($debug == 1){ if ($out['volts'] != ''){ print "Conversion [V3] √ P x R : ".$out['volts']." = ".sqrt($in['watts']." * ".$in['ohms']).";
"; }; } }; // ===== AMPS ================================== if ($out['amps'] == ''){ if ( ($in['volts'] != '') && ($in['ohms']) ){ $out['amps'] = $in['volts'] / $in['ohms']; }; if ($debug == 1){ if ($out['amps'] != ''){ print "Conversion [A1] I = V⁄R : ". $out['amps']." = ".$in['volts']." / ".$in['ohms'].";
"; }; } }; if ($out['amps'] == ''){ if ( ($in['watts'] != '') && ($in['volts']) ){ $out['amps'] = $in['watts'] / $in['volts']; }; if ($debug == 1){ if ($out['amps'] != ''){ print "Conversion [A2] I = P⁄V : ". $out['amps']." = ".$in['watts']." / ".$in['volts'].";
"; }; } }; if ($out['amps'] == ''){ if ( ($in['watts'] != '') && ($in['ohms']) ){ $out['amps'] = sqrt($in['watts'] / $in['ohms']); }; if ($debug == 1){ if ($out['amps'] != ''){ print "Conversion [A3] I = √ P⁄R : ".$out['amps']." = sqrt(".$in['watts']." / ".$in['ohms'].");
"; }; } }; // ===== ['watts'] ================================== if ($out['watts'] == ''){ if ( ($in['volts'] != '') && ($in['amps'] != '') ){ $out['watts'] = $in['volts'] * $in['amps']; }; if ($debug == 1){ if ($out['watts'] != ''){ print "Conversion [W1] I = √ P⁄R : ".$out['amps']." = sqrt(".$in['watts']." / ".$in['ohms'].");
"; }; } }; if ($out['watts'] == ''){ if ( ($in['volts'] != '') && ($in['ohms'] != '') ){ $out['watts'] = pow($in['volts'],2) / $in['ohms']; }; if ($debug == 1){ if ($out['watts'] != ''){ print "Conversion [W2] P = V2⁄R : ".$out['watts']." = pow(".$in['volts'].",2) / ".$in['ohms'].";
"; } }; }; if ($out['watts'] == ''){ if ( ($in['amps'] != '') && ($in['ohms'] != '') ){ $out['watts'] = pow($in['amps'],2) * $in['ohms']; }; if ($debug == 1){ if ($out['watts'] != ''){ print "Conversion [W3] P = I2 x R : ".$out['watts']." = pow(".$in['amps'].",2) * ".$in['ohms'].";
"; }; } }; // ===== OHMS ================================== if ($out['ohms'] == ''){ if ( ($in['volts'] != '') && ($in['amps']) ){ $out['ohms'] = $in['volts'] / $in['amps']; }; if ($debug == 1){ if ($out['ohms'] != ''){ print "Conversion [R1] R = V⁄I :".$out['ohms']." = ".$in['volts']." / ".$in['amps'].";
"; }; } }; if ($out['ohms'] == ''){ if ( ($in['volts'] != '') && ($in['watts']) ){ $out['ohms'] = pow($in['volts'],2) / $in['watts']; }; if ($debug == 1){ if ($out['ohms'] != ''){ print "Conversion [R2] R = V2⁄P : ".$out['ohms']." = pow(".$in['volts'].",2) / ".$in['watts'].";
"; }; } }; if ($out['ohms'] == ''){ if ( ($in['watts'] != '') && ($in['amps']) ){ $out['ohms'] = $in['watts'] / pow($in['amps'],2); }; if ($debug == 1){ if ($out['ohms'] != ''){ print "Conversion [R3] R = P⁄I2 : ".$out['ohms']." = ".$in['watts']." / pow(".$in['amps'].",2);
"; }; } }; }; // Fix for PHP 8.0 if (is_numeric($out['volts'])){ $out['volts'] = round($out['volts'], 3); }; if (is_numeric($out['amps'])) { $out['amps'] = round($out['amps'], 3); }; if (is_numeric($out['watts'])){ $out['watts'] = round($out['watts'], 3); }; if (is_numeric($out['ohms'])) { $out['ohms'] = round($out['ohms'], 3); }; // Find our in/out highlighting colors. if ($in['volts'] == $out['volts']){ $out_hl['volts'] = "outfield"; }else{ $out_hl['volts'] = "outfieldcalc"; }; if ($in['amps'] == $out['amps']){ $out_hl['amps'] = "outfield"; }else{ $out_hl['amps'] = "outfieldcalc"; }; if ($in['watts'] == $out['watts']){ $out_hl['watts'] = "outfield"; }else{ $out_hl['watts'] = "outfieldcalc"; }; if ($in['ohms'] == $out['ohms']){ $out_hl['ohms'] = "outfield"; }else{ $out_hl['ohms'] = "outfieldcalc"; }; print " "; ?>
Power Calculator
Calculate Volts, Amps, ['watts'], or Ohms
Give any 2 values. The other 2 are calculated.
  Input Unit Calculated
Voltage Volts ".$out['volts']." V
Intensity Amps ".$out['amps']." A
Power Watts ".$out['watts']." W
Resistance Ω Ohms ".$out['ohms']." Ω


"; print "
Details
Voltage
[V]
The measure of the power differental between two points. It is the electromotive force. This is measured in volts [V].
Current Iintensity
[I]
The flow of electric charge across a surface. This is measured in amps [A].
Power
[P]
The rate of energy transfer. This is measured in ['watts'] [W].
Resistance
[R]
The rate of energy transfer. This is measured in ohms [Ω].
Formulas
To find Known Formula
Volts Amps [I]
Resistance Ω
V = I x R
Volts Watts [P]
Amps [I]
V = PI
Volts Watts [P]
Resistance Ω
 P x R 
Amps [I]
Volts
Resistance Ω
I = VR
Amps [I]
Watts [P]
Volts
I = P V
Amps [I]
Watts [P]
Resistance Ω
I =  PR 
Watts [P]
Volts
Amps [I]
P = V x I
Watts [P]
Volts
Resistance Ω
P = V2R
Watts [P]
Amps [I]
Resistance Ω
P = I2 x R
Resistance Ω Volts
Amps [I]
R = VI
Resistance Ω Volts
Watts [P]
R = V2P
Resistance Ω Watts [P]
Amps [I]
R = PI2
AB */ ?>