0

So I purchased a script package which is using eregi_replace and I do not know how to re-write the code to play with preg_replace()

The error is: Deprecated: Function eregi_replace() is deprecated in /home2/leemonster/scripttk.com/helpDesk/inc/header.php on line 19

The code is:

if (isset($theme_dir)) 
    $temp = preg_replace('/( href=")([^>]*?eticket\.css")/is', '$1' . $theme_dir . '$2', $temp);

if (isset($page)) 
    $temp = str_replace('admin.php', $page, $temp);
if (isset($page)) 
    $temp = str_replace('index.php', $page, $temp);

$header = eregi_replace($bodytag . '.*', '', $temp);
$footer = eregi_replace('.*' . $bodytag, '', $temp);
Mohammad
  • 21,175
  • 15
  • 55
  • 84
DDavis
  • 3
  • 1

1 Answers1

0
$header = preg_replace('/' . $bodytag . '.*/i', '', $temp);
$footer = preg_replace('/.*' . $bodytag . '/i', '', $temp);

I've added a delimiter, / in this case (can be other characters too), that needs to surround all preg regular expressions, as well as the i flag that makes the match case-insensitive. Just make sure that $bodytag doesn't contain said delimiters unescaped.

I'd recommend you read up on how the preg suite works, here's a good place to start.

Mav
  • 1,087
  • 1
  • 15
  • 37
  • Thank you so much. Your answer was spot on. I will take your advise and read up on the subject. – DDavis Oct 28 '18 at 13:55