Hello,

Sign up to join our community!

Welcome Back,

Please sign in to your account!

Forgot Password,

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

You must login to ask a question.

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

BashCow Latest Questions

  • 30
  • 30
rylan98

Warning: preg_replace(): Unknown modifier

I have the following error:

Warning: preg_replace(): Unknown modifier ']' in xxx.php on line 38

This is the code on line 38:

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

How can I fix this problem?

Related Questions

1 Answer

  1. This answer was edited.

    If you prefer to receive an exception (MalformedPatternException) instead of warnings or relying on preg_last_error(), consider using the T-Regx library: <?php try { return pattern('invalid] pattern')->match($s)->all(); } catch (MalformedPatternException $e) { // your pattern was invalid }

    If you prefer to receive an exception (MalformedPatternException) instead of warnings or relying on preg_last_error(), consider using the T-Regx library:

    <?php
    try 
    {
    return pattern('invalid] pattern')->match($s)->all();
    }
    catch (MalformedPatternException $e) 
    {
    // your pattern was invalid
    }
    See less
Leave an answer

Leave an answer