如果replace你的意思是删除所有嵌套< TR>和< TD>在$文本标签并插入$ NEW_TEXT(其中包含嵌套< TD>标签一对夫妇< TR>标签的,但没有标签)在他们的位置;那么使用preg_replace可能会有所斩获。下面的代码片段显示了如何:
IF $ something,$ var1 THROUGH $ var4,$ new_var1 THROUGH $ new_var44 ARE REAL VARIABLES;下面的代码段将采取处理这件事...
$text = "
{$something} | ||
{$var1} {$var2} | {$var3} | {$var4} |
{$something} |
$new_text = "
{$new_var1} {$new_var2}{$new_var3}{$new_var4}{$new_var11} $new_var22}{$new_var33}{$new_var44}";// THIS WILL REMOVE EVERYTHING BETWEEN
// IN $text AND REPLACE THEM WITH THE CONTENTS OF $new_text
$result = preg_replace("#(
)(.*)()#si", "$1{$new_text}$3", $text);IF $的东西,$ VAR1 THROUGH VAR4 $,$ new_var2到$ new_var44是保存没有价值只是字符串;下面的代码片段会照顾的那...
$text = "
\$something | ||
\$var1 \$var2 | \$var3 | \$var4 |
\$something |
$new_text = "
\$new_var1 \$new_var2\$new_var3\$new_var4\$new_var11 \$new_var22\$new_var33\$new_var44";// THIS WILL REMOVE EVERYTHING BETWEEN
// IN $text AND REPLACE THEM WITH THE CONTENTS OF $new_text
$result = preg_replace("#(
)(.*)()#si", "$1{$new_text}$3", $text);echo ($result);
欢呼和好运;-)