相关疑难解决方法(0)

警告:preg_replace():未知的修饰符']'

我有以下错误:

警告:preg_replace():第38行的xxx.php中的未知修饰符']'

这是第38行的代码:

<?php echo str_replace("</ul></div>", "", preg_replace("<div[^>]*><ul[^>]*>", "", wp_nav_menu(array('theme_location' => 'nav', 'echo' => false)) )); ?>
Run Code Online (Sandbox Code Playgroud)

有人可以帮我解决这个问题吗?

php regex wordpress preg-replace

43
推荐指数
2
解决办法
3万
查看次数

preg_replace:未知修饰符

假设$ body等于

something 
that 
does 
not 
interest 
me 
<!-- start -->
some
html
code
<!-- end -->
something
that
does
not
interest
me
Run Code Online (Sandbox Code Playgroud)

如果我使用

$body=preg_replace("(.*)<!-- start -->(.*)<!-- end -->(.*)","$2",$body);
Run Code Online (Sandbox Code Playgroud)

我获得:

something 
that 
does 
not 
interest 
me 
<!-- start -->
some
html
code
<!-- end -->
something
that
does
not
interest
me
Run Code Online (Sandbox Code Playgroud)

我该如何纠正?

php preg-replace

5
推荐指数
1
解决办法
2万
查看次数

标签 统计

php ×2

preg-replace ×2

regex ×1

wordpress ×1