user1764987
user1764987

Reputation: 29

Function ereg_replace() is deprecated - Cannot fix

I have the above error that I am struggling to fix, the code can be seen below:

$anchor = ereg_replace($pattern, '', strtolower($string));
            $pattern = "([[:space:]]|[[:blank:]])+"; 
            $anchor = ereg_replace($pattern, '-', $anchor);
            return $this->short_name($anchor); // return the short filtered name 

Just to add, I have amended to this:

 $anchor = ereg_replace($pattern, '', strtolower($string));
            $pattern = "/([[:space:]]|[[:blank:]])+/"; 
            $anchor = ereg_replace($pattern, '-', $anchor);
            return $this->short_name($anchor); // return the short filtered name

But still the error persists and it points to the first and 3rd line as the problem.

Any help appreciated, i have look at other threads and Google but couldnt find the resolution.

Thanks.

Upvotes: -2

Views: 234

Answers (1)

Michal Brašna
Michal Brašna

Reputation: 2323

ereg_* functions are deprecated user preg_* functions. Don't forget to surround you pattern with delimiters like below.

$pattern = "/([[:space:]]|[[:blank:]])+/"; 
$anchor = preg_replace($pattern, '-', $anchor);

Upvotes: 0

Related Questions