You could use variable variables. Or you can use arrays. Whatever you pick will cut down on the final number of lines of PHP you have to write, but you'll still probably have to maintain the list of variables being filtered.
<?php
// VARIABLE VARIABLES APPROACH
$search = array( '$', ',' ); // Add any other possible punctuation
$replace = '';
$tmp_other_servicefee = $node->field_other_servicefee[0]['value']; // values like this go into temp variables
// just add any variables to filter to this array
$vars = array( 'calc_template', 'calc_install', 'calc_tearout', 'calc_rasiect',
'calc_surcharge', 'tmp_other_servicefee' );
foreach( $vars as $var ) {
if( is_string( ${$var} ) ) {
${$var} = str_replace( $search, $replace, ${$var} );
}
}
// note that since you are performing addition only, you can compute $svc_total
// during the loop as i've done with the "ARRAY APPROACH" below
// if you are doing mixed operations, i.e. division, addition, multiplication, etc
// then you are best off performing the calculation in steps that clearly outline
// the order of operations.
$svc_total= $calc_template + $calc_install + $calc_tearout + $calc_rasiect + $calc_surcharge + $tmp_other_servicefee;
$svc_total= number_format($svc_total, 2, '.', ',');
print check_plain ($svc_total, 2);
?>
<?php
// ARRAY APPROACH
// This approach will lend itself best when the operator is the same for all of them
// (in your case: addition)
$search = array( '$', ',' ); // Add any other possible punctuation
$replace = '';
$values = array();
$values[] = $calc_template;
$values[] = $calc_install;
$values[] = $calc_tearout;
$values[] = $calc_rasiect;
$values[] = $calc_surcharge;
$values[] = $node->field_other_servicefee[0]['value'];
$svc_total = 0;
foreach( $values as $key => $val ) {
if( is_string( $val ) ) {
$val = str_replace( $search, $replace, $val );
}
$svc_total += $val;
}
$svc_total= number_format($svc_total, 2, '.', ',');
print check_plain ($svc_total, 2);
?>