I'm in the process of migrating a horrible drupal site to a new server - a server with a newer version of PHP. Checking the site I get the following error:
Deprecated: Function ereg() is deprecated in /var/sites/n/nanohex.org/public_html/includes/file.inc on line 902
Line 902 looks like the following:
elseif ($depth >= $min_depth && ereg($mask, $file)) {
My understanding is that ereg is no longer used and I need to replace with pregmatch.
Changing the code the following...
elseif ($depth >= $min_depth && preg_match('/\.([^\.]*$)/', $mask, $file)) {
throws up this error instead:
Warning: basename() expects parameter 1 to be string, array given in /var/sites/n/nanohex.org/public_html/includes/file.inc on line 905
Line 905 looks like this:
$basename = basename($file);
What am I doing wrong?
The matches are in the array $file
. You have to use the second entry in this array:
$basename = basename($file[1]);
But I guess your preg_match should be:
preg_match('/\.([^\.]*$)/', $file)
and then:
$basename = basename($file);
is OK.