I have three columns of data coming in from a form. My goal is to add decimal places to each entry if the fields are left blank. For example, I have BMI, height, and weight. BMI will have one decimal place if the form field is left blank, resulting in 0.0. For weight, it will be 0.00 and so on.
Here is the code I have now which handles the BMI form field.
$return['is_spouse'] = ($return['is_spouse'] == 1) ? 'Yes' : 'No';
if($biometric_data) {
foreach(self::$biometric_fields as $column_name) {
if($column_name == 'bmi') {
$biometrics[$column_name] = number_format($bio[$column_name], 1);
continue;
}
$biometrics[$column_name] = $bio[$column_name];
}
}
//When attempting to add the height or weight parts to the code, BMI becomes a blank result //and the number format gets applied to the height only, as if that section of the code gets //skipped.
$return['is_spouse'] = ($return['is_spouse'] == 1) ? 'Yes' : 'No';
if($biometric_data) {
foreach(self::$biometric_fields as $column_name) {
if($column_name == 'bmi') {
$biometrics[$column_name] = number_format($bio[$column_name], 1);
continue;
}
$biometrics[$column_name] = $bio[$column_name];
}
}
$return['is_spouse'] = ($return['is_spouse'] == 2) ;
if($biometric_data) {
foreach(self::$biometric_fields as $column_name) {
if($column_name == 'height') {
$biometrics[$column_name] = number_format($bio[$column_name], 2);
continue;
}
$biometrics[$column_name] = $bio[$column_name];
}
}
Pretty new to PHP. Thanks for your assistance.
Aucun commentaire:
Enregistrer un commentaire