space ranger
space ranger

Reputation: 422

How to bold a variable?

How can I have text within a php variable be bold??

function show_balance_header ($balance, $currency)
{
    (string)$display_output = null;
    $display_output = fees_main::display_amount(abs($balance), $currency, true);
    return $display_output;
}

I want to bold $balance. Is there an easy way or do I need to edit display_amount?

I've tried doing this:

"<b>".$balance"</b>" but this did not get the correct variable,

thanks in advance!!

Upvotes: 2

Views: 28145

Answers (3)

space ranger
space ranger

Reputation: 422

answer is to edit the inner function display_amount using Raeki's suggestion, for future questions, i think you must edit the inner-most function as only editing function show_balance_header did not get the correct variable

Upvotes: 0

Raekye
Raekye

Reputation: 5131

Needs to be "<b>" . $balance . "</b>". Concatenate <b> to $balance and concatenate again to </b>


Edit: Assuming this does the printing/formatting: fees_main::display_amount(abs($balance)

You want fees_main::display_amount('<b>' . abs($balance) . '</b>', $currency, true). abs($balance) gets the absolute value as a number, and the concatenation (explained above) automatically casts them to strings. The rest of the parameters are passed the same way (unmodified, unbolded).

(string)$display_output = null; is unnecessary

Upvotes: 5

Ricardo Lohmann
Ricardo Lohmann

Reputation: 26320

On your element html, example:

<p> text <?php echo "<b>{$balance}</b>"; ?> text</p>

Upvotes: 0

Related Questions