xiaix Posted August 26, 2009 Share Posted August 26, 2009 This code: if ($data1["e"] > 0) { $part .= sprintf("<strong>%s %d %s</strong>", $data1["e"] > 0 ? "+":"-", $data1["e"], $defType["e"]); if ($howManyArmorDef > ($e1 += 1)) { $part .= "<BR />"; }} Displays this: +54 Melee Piercing Defense Fine, but if I use this code (notice the %5s): if ($data1["e"] > 0) { $part .= sprintf("<strong>%s %d %5s</strong>", $data1["e"] > 0 ? "+":"-", $data1["e"], $defType["e"]); if ($howManyArmorDef > ($e1 += 1)) { $part .= "<BR />"; }} I still get this: +54 Melee Piercing Defense But I should get this: +54 Melee Piercing Defense What gives? What am I doing wrong? Thanks. Quote Link to comment Share on other sites More sharing options...
ignace Posted August 26, 2009 Share Posted August 26, 2009 the padding is there however HTML does not show padding in order to display it either wrap it in pre or code tags or assign an id or class to the element and via CSS add the line: white-space: pre; Quote Link to comment Share on other sites More sharing options...
xiaix Posted August 26, 2009 Author Share Posted August 26, 2009 Ah, gotcha. I was scratching my head for hours as to why it wouldn't work. Didn't know that HTML wouldn't display padding like that. I'll use your advise with the <pre / > tags. Thanks for the quick response. Quote Link to comment Share on other sites More sharing options...
xiaix Posted August 26, 2009 Author Share Posted August 26, 2009 *update* <pre> tags got messy, and after much trying to get things to pad correctly, I gave up and opted for table/row/columns to handle my text padding/justification issues. Everything works great now. Example: // Let's list armor defenses if ($howManyArmorDef>0) { $part .= sprintf("<BR /><strong>Defenses</strong><BR />"); $part .= sprintf("<table>"); if ($data1["e"] > 0) { $part .= sprintf("<tr><td>%+d</td><td>[%s]</td></tr>", $data1["e"], $defType["e"]); } if ($data1["f"] > 0) { $part .= sprintf("<tr><td>%+d</td><td>[%s]</td></tr>", $data1["f"], $defType["f"]); } if ($data1["g"] > 0) { $part .= sprintf("<tr><td>%+d</td><td>[%s]</td></tr>", $data1["g"], $defType["g"]); } if ($data1["h"] > 0) { $part .= sprintf("<tr><td>%+d</td><td>[%s]</td></tr>", $data1["h"], $defType["h"]); } if ($data1["i"] > 0) { $part .= sprintf("<tr><td>%+d</td><td>[%s]</td></tr>", $data1["i"], $defType["i"]); } if ($data1["j"] > 0) { $part .= sprintf("<tr><td>%+d</td><td>[%s]</td></tr>", $data1["j"], $defType["j"]); } $part .= sprintf("</table>"); } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.