Riparian Posted May 30, 2011 Share Posted May 30, 2011 Hi Can someone point me in the right direction. I can force php to put a Plus(+) sign in front of positive numbers with printf('%0+4.2f',$x) But I cant get this to work inside <option>printf('%0+4.2f',$x)</option> tags Any help is greatly appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/237822-help-with-plus-and-minus/ Share on other sites More sharing options...
fugix Posted May 30, 2011 Share Posted May 30, 2011 why dont you use the html code for + + Quote Link to comment https://forums.phpfreaks.com/topic/237822-help-with-plus-and-minus/#findComment-1222134 Share on other sites More sharing options...
Riparian Posted May 30, 2011 Author Share Posted May 30, 2011 Thanks for the help but finally got it working with the following <OPTION VALUE="<?=$x?>"><?php printf('%0+2.2f', $x)?></OPTION> For others this displays a plus in front of positive numbers only (the 2.2 is the decimal points required) $x is the display value I was chasing Hope it helps someone Cheers Quote Link to comment https://forums.phpfreaks.com/topic/237822-help-with-plus-and-minus/#findComment-1222142 Share on other sites More sharing options...
Pikachu2000 Posted May 30, 2011 Share Posted May 30, 2011 why dont you use the html code for + + ^^^ That has nothing to do with it. ^^^ Assuming this is within an echo statement, you need to concatenate the function's output into the string. echo "<option>" . printf('%0+4.2f',$x) . "</option> '; Quote Link to comment https://forums.phpfreaks.com/topic/237822-help-with-plus-and-minus/#findComment-1222144 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.