Forum Moderators: coopster

Message Too Old, No Replies

Number Format in an output.

number format in an echoed td element.

         

ski442

8:59 pm on Feb 8, 2010 (gmt 0)

10+ Year Member



Hi Guys.
I need some help on how to output this correctly.
This is what i have.
echo "<td id='right' height='25'>&pound;$offerprice</td>"; }?>

And this is what I would like,
echo number_format "<td id='right' height='25'>&pound;($offerprice, 2, ".", ",");</td>"; }?>

I have been messing aroung with " and ' and swapping them but no good, so there must be a better way, yea?

Any Help would be great.
Thanks Very Much
Ski442

Matthew1980

9:19 pm on Feb 8, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



HI ski442,


echo number_format "<td id='right' height='25'>&pound;($offerprice, 2, ".", ",");</td>";}?>


try:-


echo "<td id='right' height='25'>&pound;".number_format($offerprice, 2, ".", ",")."</td>";

}//guessing as this closes an if
?>


Give it a try, I might be wrong but that looks about right to me, apologies if its wrong... All I have done is concatenate the function into the echo.

Cheers,

MRb

[edited by: Matthew1980 at 9:36 pm (utc) on Feb 8, 2010]

dreamcatcher

9:19 pm on Feb 8, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi ski442,

You can`t pass HTML into the number_format function. Needs to be simply:

echo "<td id='right' height='25'>&pound;".number_format($offerprice, 2, ".", ",")."</td>";

dc

edit: Matthew1980 beat me to it. ;)

Matthew1980

9:28 pm on Feb 8, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hey DC,

Well at least that proves I was right, I hoped I was ;-p Phew!

Cheers,

MRb

ski442

9:37 pm on Feb 8, 2010 (gmt 0)

10+ Year Member



Hi Guys.
Thanks very much,
It was an if, but i only put in the code i needed changing, sorry should of said.
But works great, note to self, try more options next time.
Thanks Again Guys.
Ski442