0
我想用PHP爲文本文件添加300個空格。我不能像你已經知道的那樣使用 
(.txt格式,而不是HTML),那麼如何做到這一點?用PHP爲文本文件添加300個空格
所以這段代碼會計算數字,你可以看到,我需要300個空格。
$spaces = 0; // will become 300 spaces
while ($spaces < 300)
{
$spaces++;
}
以及測試多少的空格我有我會用
substr_count($spaces, ' ');
感謝
'$ zerospaces =「你好」; $ spaces = str_pad($ zerospaces,300,「」,STR_PAD_LEFT); $ spacecount = substr_count($ spaces,「」); echo $ spacecount。$ spaces;''有'295 hello'輸出,'count和hello'之間沒有300個空格 – MOTIVECODEX
@ F4LLCON如果你只需要300個空格,沒有填充的文本是300個字符,然後在一個str_pad上運行空變量,像這樣 $ spaces = str_pad(「」,300,「」); – TravisO
@TravisO更好的是,如果你實際上沒有做任何填充,只需使用['str_repeat('',300);'](http://php.net/str_repeat)。 – Wiseguy