Jump to content

Difference


rashmi_k28

Recommended Posts

Hi,

 

Is there any way to differentiate between 0 and 0.00.

 

$a=0;

$b=0.00;

 

In a function I have to assign color 
function FCallback($aVal) {

    if( $aVal == 0 ) $c = "red";
    elseif( $aVal == '0.00' ) $c = "black";
    else $c="green";
    return array(3,"",$c);
}

 

But if aVal is 0 and 0.00 same color is printed. Is there anyway to differentiate between the two.

 

 

Link to comment
https://forums.phpfreaks.com/topic/110388-difference/
Share on other sites

Hi there, yes there is, just use === for comparison (and I removed quotes around 0.00 as it's not a string):

 

<?php
function FCallback($aVal) {

    if( $aVal === 0 ) $c = "red";
    elseif( $aVal === 0.00 ) $c = "black";
    else $c="green";
    return array(3,"",$c);
}
?>

Link to comment
https://forums.phpfreaks.com/topic/110388-difference/#findComment-566344
Share on other sites

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.