dslreports logo
site
 
    All Forums Hot Topics Gallery
spc

spacer




how-to block ads


Search Topic:
uniqs
41
share rss forum feed


JAAulde
Web Developer
Premium,MVM
join:2001-05-09
Williamsport, MD
kudos:3

1 edit

1 recommendation

reply to ProtusMose

Re: Printing percentage sign in PHP

I assume you're running `$OutputHTMLTemplate` through `sprintf()` or something similar. If so, then as you know, `%` within the string tells `sprintf()` to replace it and its following specifier with one of the value parameters. If you desire a literal `%` to be outputted in your string and not included as one of the format directives to `sprintf()`, the documents say to use a double percent sign (%%).

So your code would look like:

$OutputHTMLTemplate = <<<EOHTML
<table class="col1">
<tr class="trtn"><td class="td1">Ticker Symbol:</td><td class="td2">XXXXXX</td></tr>
<tr class="trwh"><td class="td1">CUSIP Number:</td><td class="td2">XXXXXXXXX</td></tr>
<tr class="trtn"><td class="td1">Inception Date:</td><td class="td2">XXXXX</td></tr>
<tr class="trwh"><td class="td1">Total Net Asets (in millions):</td><td class="td2">XXXX</td></tr>
<tr class="trtn"><td class="td1">&nbspNet Asset Value (NAV) %s:</td><td class="td2">$%s</td></tr>
<tr class="trwh"><td class="td1">Expense Ratio:</td><td class="td2">2.3%%</td></tr>
<tr class="trtn"><td class="td1">Portfolio Turnover:</td><td class="td2">20%%</td>
</table>
EOHTML;
 

(notice the 2.3%% and 20%%)

I further assume the whole thing grinds to a halt due to an error being generated when the string you're giving is assumed to have 4 format directives but you're only passing 2 value params.

--
The Yakabox | My Development Sandbox | LinkedIn Profile


ProtusMose
Immortal. Eternal.
Premium
join:2001-10-03
Bellevue, NE
kudos:4
Reviews:
·ooma

vprintf is what's doing the output.

Actually, I'm pretty sure you wrote this last year. (The handling of the import) I'm just changing the output for a new version of the site.

The %% worked perfectly, so thank you for the second time.

Now I just have to figure out why the CSS isn't properly affecting the include the way it does if the table is planted straight in the page.
--
Blogsaus "Everyone bows to something. Everyone answers to someone. Wherever your treasure lies, there your heart will be also.

Who do you belong to? " - Andrew Schwab



JAAulde
Web Developer
Premium,MVM
join:2001-05-09
Williamsport, MD
kudos:3
reply to JAAulde

Cool, glad it helped. I do remember writing that--only time I've ever used `vprintf()`! :P