Function eregi() is deprecated Error message

Hello,

We have switched to a new server with latest Php version and all of a sudden are getting Error message:

Function eregi() is deprecated in…

We are using eregi() in this way to see that Fotos uploaded have filetype JPG, GIF PNG:

if (eregi(‘^image/p?jpeg(;.*)?$’, $_FILES[‘uploadedfile’][‘type’])) {
$filetype = ‘jpg’;
}

The documentation says replace eregi with preg_match, which we did as here:

if (preg_match(‘^image/p?jpeg(;.*)?$’, $_FILES[‘uploadedfile’][‘type’])) {
$filetype = ‘jpg’;
}

but when we do this produces Error message:

Warning: preg_match(): No ending delimiter ‘^’ found in

So what is the right method for replacing the eregi() is deprecated?

ThanX.

Surround the expression in the preg_match within delimiters - any character not in the string makes a good delimiter for example

if (preg_match('@^image/p?jpeg(;.*)?$@', $_FILES['uploadedfile']['type'])) {

Thanks. Your suggestion seems to be working just fine.
You are the Php man :slight_smile: