Jump to content

PHP if else rounding and conditional formatting frustration


ajc1502

Recommended Posts

Hi New but learning fast...

I am trying to achieve echo or printing a $variable which is a number. I would like it to display red if negative or black is positive! I also need to round the number to 0. i.e -34.32345 becomes -34

I have achieved each independently but if I try and add rounding it breaks the code??? So I need to know how to add rounding to the variable $variancemonth in the following code.

 

<?php

  if ($differencemonth <= 0 ){

print "Variance Month <font color=\"red\">£$differencemonth</font>";

}

else {

print "Variance Month <font color=\"000000\">£$differencemonth</font>";

}

?>

Any help would be appreciated.

 

Regards

 

Andy

ps I can find examples of both rounding and formatting independently but not used together.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.