Jump to content

Help with Plus and Minus


Riparian

Recommended Posts

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.

 

Link to comment
Share on other sites

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

 

 

Link to comment
Share on other sites

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> ';

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.