how to change old ereg? [message #181937] |
Wed, 26 June 2013 04:41 |
astrid.kuhr
Messages: 5 Registered: June 2013
Karma:
|
Junior Member |
|
|
Hello!
On a webpage I am using phpweather.
It works fine for several years.
But now it causes very many error messages.
I searched in the web, that ereg is not
longer supported and it is to replace with
preg_match.
I try to do this and change
if (ereg("^pw_${type}_([a-z][a-z])(_[A-Z][A-Z])?\.php$", $file, $regs)) {
$output[$regs[1] . $regs[2]] = $languages[$regs[1] . $regs[2]];
}
to
if (preg_match("/^pw_${type}_([a-z][a-z])(_[A-Z][A-Z])?\.php$/", $file, $regs)) {
$output[$regs[1] . $regs[2]] = $languages[$regs[1] . $regs[2]];
}
But now appears:
Notice: Undefined offset: 2 in /var/www/html/phpweather/pw_utilities.php on line 95
But I do not know php.
} elseif (ereg_match('^M?(([0-9]?)[ ]?([0-9])(/?)([0-9]*))SM$',
$temp_visibility_miles . ' ' . $part, $regs)) {
I changed to
} elseif (preg_match('/^M?(([0-9]?)[ ]?([0-9])(/?)([0-9]*))SM$/',
$temp_visibility_miles . ' ' . $part, $regs)) {
But then:
Warning: preg_match() [function.preg-match]: Unknown modifier '?' in /var/www/html/phpweather/phpweather.php on line 329
And very very many other error-messages to.
How can I change it to get it work?
Regards, Astrid
|
|
|