rashmi_k28 Posted June 16, 2008 Share Posted June 16, 2008 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 More sharing options...
zenag Posted June 16, 2008 Share Posted June 16, 2008 function FCallback($aVal) { if( strlen($aVal )== 1 ) $c = "red"; elseif( strlen($aVal )== 4) $c = "black"; else $c="green"; return array(3,"",$c); } Link to comment https://forums.phpfreaks.com/topic/110388-difference/#findComment-566338 Share on other sites More sharing options...
thebadbad Posted June 16, 2008 Share Posted June 16, 2008 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.