我想格式化文本,但我不知道该怎么办。PHP文本格式的文本凌乱
我有文字:
Row1
Row2
Title
text _ text
text _ text
Row1
Row2
Title
text _ text
text _ text
我想修改它
Title
text : text
text : text
Title
text : text
text : text
我想删除ROW1和2,但仍高于空行。
要删除两行文本和文本之间的空白在
和改造_ in :
我尝试使用str_replace函数和preg_replace函数,但我不知道该怎么办。
前
<?php
if(isset($_POST["submit"])) {
$text = $_POST["text-ed"];
$change = ' _ ';
$change_r = ' : ';
$remove_line = array("\n", "\r");
$rezult = preg_replace('/[\n\r]+/', '', $text);
$rezult = str_replace(array($remove_line, $change), array('', $change_r), $text);
}
?>
? – 2015-04-06 12:13:00
我想删除文本下面的Row1,Row2和空行:text。 – Adrian 2015-04-06 12:17:04
“Row1/Row2”文字或包含一些文本的行吗? – 2015-04-06 12:18:12