Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 299
  • Last Modified:

PHP sprintf

sprintf('"%s" <%s> (%s) [%s]', a, b, c, d);

will not display <%s>

I get "a" (c) [d] not "a" <b> (c) [d]

do I need some escape character or something?
0
mosemadl
Asked:
mosemadl
  • 3
  • 2
  • 2
  • +1
1 Solution
 
Dave BaldwinFixer of ProblemsCommented:
Yes, all the options for use in sprintf() are on this page: http://www.php.net/manual/en/function.sprintf.php  To actually display a '%', you need two of them '%%'.
0
 
Chris StanyonCommented:
If you're outputting this in HTML you won't see the bit between <> because your page will think it's an HTML tag. View the source of your page and you'll see it, but to render the < and > in HTML you need to use the HTML entities &lt; and &gt;

sprintf('"%s" &lt;%s%gt; (%s) [%s]', a, b, c, d);

Open in new window

0
 
Greg AlexanderLead DeveloperCommented:
Just a thought

<?= sprintf('"%s" &lt;%s&gt; (%s) [%s]', a, b, c, d); ?>

Open in new window

0
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
Greg AlexanderLead DeveloperCommented:
Sorry, didn't see that... don't give me points ;)
0
 
mosemadlAuthor Commented:
I don't need %

I need <b>

The less than symbol is the issue.
0
 
Chris StanyonCommented:
@mosemadl - have you just cross-posted or did you miss my post completely?
0
 
mosemadlAuthor Commented:
Sorry galexander07. That's exactly it.
0
 
Chris StanyonCommented:
I seem to be having another invisible day :/
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now