我有在未來一個字符串的多行檢查字符是一個多行字符串,根據輸入的格式稍有不同PHP上的繩子
1. Qatar 2. Qatar 3 . Cathay 4. Qatar 2 . British 3. Qantas
我想要的輸出字符串具有相同格式的所有行:
1 . Qatar 2 . Qatar 3 . Cathay 4 . Qatar 2 . British 3 . Qantas
我可以使它檢查使用
$fullstop = substr("$input", 2); //isolate character 2
if (strpos($fullstop, '.') !== false) { //check is the character in pos 2 is a .
$output = str_replace("."," .",$fullstop); //replace the full stop with space fullstop
}
釷第一線對於第一行來說工作正常,但是我希望代碼對所有代碼行都做同樣的事情。
任何想法?
你的琴絃之上都有第一個數字(例如 「1 Quatar」)前的空白(空格)字符。這是一個錯字嗎? – BeetleJuice
只是用'space-dot'替換'space-dot's和'dot',對吧? – mickmackusa