Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #9889
| Message-ID | <1617251.umBanJLiFt@PointedEars.de> (permalink) |
|---|---|
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
| Organization | PointedEars Software (PES) |
| Date | 2013-06-26 11:47 +0200 |
| Subject | Re: how to change old ereg? |
| Newsgroups | comp.lang.php |
| References | <f60593e2-b741-40ba-9355-dcbfd41ac386@googlegroups.com> |
astrid.kuhr@gmail.com wrote:
> 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.
Learn it.
> } elseif (ereg_match('^M?(([0-9]?)[ ]?([0-9])(/?)([0-9]*))SM$',
> $temp_visibility_miles . ' ' . $part, $regs)) {
There is no built-in ereg_match() function.
> 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?
RTFM:
<http://php.net/ereg>
<http://php.net/preg_match>
PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
how to change old ereg? astrid.kuhr@gmail.com - 2013-06-25 21:41 -0700
Re: how to change old ereg? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-06-26 11:47 +0200
Re: how to change old ereg? Astrid <astrid.kuhr@gmail.com> - 2013-06-26 04:29 -0700
Re: how to change old ereg? tony@mountifield.org (Tony Mountifield) - 2013-06-26 11:57 +0000
Re: how to change old ereg? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-06-26 14:13 +0200
PREG \d vs. [0-9] (was: how to change old ereg?) Christoph Michael Becker <cmbecker69@arcor.de> - 2013-06-26 16:42 +0200
Re: PREG \d vs. [0-9] Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-06-26 18:02 +0200
Re: how to change old ereg? Gregor Kofler <usenet@gregorkofler.com> - 2013-06-26 21:34 +0200
Re: how to change old ereg? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-06-27 01:18 +0200
Re: how to change old ereg? The Natural Philosopher <tnp@invalid.invalid> - 2013-06-27 12:55 +0100
Re: how to change old ereg? Astrid <astrid.kuhr@gmail.com> - 2013-06-26 05:24 -0700
Re: how to change old ereg? Astrid <astrid.kuhr@gmail.com> - 2013-06-28 01:38 -0700
Re: how to change old ereg? tony@mountifield.org (Tony Mountifield) - 2013-06-28 09:02 +0000
Re: how to change old ereg? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-06-28 12:39 +0200
Re: how to change old ereg? Denis McMahon <denismfmcmahon@gmail.com> - 2013-06-28 11:08 +0000
Re: how to change old ereg? Astrid <astrid.kuhr@gmail.com> - 2013-06-28 02:46 -0700
Re: how to change old ereg? Jerry Stuckle <jstucklex@attglobal.net> - 2013-06-28 08:48 -0400
csiph-web