Re: [請益] 數字對齊

看板PHP作者 (孤單異世界)時間18年前 (2007/08/18 11:16), 編輯推噓1(101)
留言2則, 2人參與, 最新討論串2/2 (看更多)
※ 引述《noguchi (耶?!)》之銘言: 我現在要產生12列4欄的文字方塊 前面會有編號 當變兩位數時文字方塊會跟著往後退一格 但我想讓他數字後一位對齊 1. 文字方塊 1. 文字方塊 2. 文字方塊 2. 文字方塊 . => 變 . . . . . 10. 文字方塊 10. 文字方塊 以下是程式碼..我可以怎麼改呢?? <? $n=12; for ($i=1; $i<=$n; $i++) { echo "&nbsp;&nbsp;&nbsp;<font face='Courier New, Courier, mono'>"; echo str_replace(" ","&nbsp;",sprintf("%4d",$i)); //4是看你要格式化幾位數 echo "</font>.&nbsp;&nbsp;&nbsp; <input type=\"text\" name=\"sid[$i]\"> <input type=\"text\" name=\"name[$i]\"> <input type=\"text\" name=\"phone[$i]\"> <input type=\"text\" name=\"email[$i]\"><br> "; } ?> -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 203.64.183.208 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.112.42.176 ※ 編輯: cfw 來自: 140.112.42.176 (08/18 11:24)

08/18 12:09, , 1F
囧 ... 我看錯了
08/18 12:09, 1F

08/19 12:15, , 2F
可以了 謝謝!
08/19 12:15, 2F
文章代碼(AID): #16ncIf-4 (PHP)
討論串 (同標題文章)
文章代碼(AID): #16ncIf-4 (PHP)