r/PHPhelp • u/marbeep • Apr 19 '25
Solved Output of function “number_format” as bold
Hi!! I’m a novice and in an Intro to Information Technologies course.
Currently, I’m trying to get the output of my number_format function to register as bold on my website.
I’ve tried to incorporate it in the same way I have for the sum of each tool, but I can’t seem to figure it out.
Here’s a line of said code:
echo ‘<tr><td>’ . ‘ <b>Tool 1:</b> SUM = ‘ . “<b>{$firstrow[0]}</b>” . ‘ and AVE = ‘ . number_format($firstrow[0] / $rows, 2) . ‘</td></tr>’;
Any and all help/advice is appreciated!
1
Upvotes
4
u/bkdotcom Apr 19 '25
number_formatoutput doesn't have <b> around itThis does though:
“<b>{$firstrow[0]}</b>”1
u/Brettles1986 Apr 19 '25
Why not assign the outputs to variables and then do the formatting in the echo, makes things easier to read.
Also you should really be doing parseInt or parseFloat depending on if decimal or not.
1
u/bulltank Apr 19 '25
Do html tags like b still work?
Might need to do <span style='font-weight: bold'>text here</span> instead of <b>text</b>