Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. php sprintf

php sprintf

Scheduled Pinned Locked Moved Web Development
phpdockerhelpquestion
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    William Engberts
    wrote on last edited by
    #1

    Hi all, When writing an email in response to a button, I compose the content of the mail from php, using (amongst others) the sprinf instruction in order to create columns with fixed widths: $msg .= sprintf ("%-10s", $item['number']); $msg .= sprintf ("%-30s", $item['product']); $msg .= sprintf ("%-5s", $item['size']); $msg .= sprintf ("%-12s", $item['color']); $msg .= sprintf ("%9d" , $item['quantity]); $msg .= sprintf ("%11.2f", $total); $msg .= "\n"; etc. However, these widths are not always the same in the different rows, resulting in extremely messy emails! I have tried replacing the spaces with periods (sprintf ("%'.-10s",.....) which still gives different column width over de rows. Does anyone have a solution for this problem please? Thanks in advance, William

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups