I have a code like this. I think it just about PHP5/PHP7 compatiable problem
 function EncodeQ ($str, $position = 'text') {
    $encoded = preg_replace("[\r\n]", '', $str);
    switch (strtolower($position)) {
      case 'phrase':
        $encoded = preg_replace("/([^A-Za-z0-9!*+\/ -])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded);
        break;
      case 'comment':
        $encoded = preg_replace("/([\(\)\"])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded);
      case 'text':
      default:
        $encoded = preg_replace('/([\000-\011\013\014\016-\037\075\077\137\177-\377])/e',
              "'='.sprintf('%02X', ord('\\1'))", $encoded);
        break;
    }
    $encoded = str_replace(' ', '_', $encoded);
    return $encoded;
  }
Please help me to fix the code, the error is following
preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead
 
    