FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » how to change old ereg?
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: how to change old ereg? [message #181938 is a reply to message #181937] Wed, 26 June 2013 09:47 Go to previous messageGo to previous message
Thomas 'PointedEars'  is currently offline  Thomas 'PointedEars'
Messages: 701
Registered: October 2010
Karma:
Senior Member
astrid(dot)kuhr(at)gmail(dot)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
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: FORMS, validating mail was sent
Next Topic: $referrer = $_SERVER['HTTP_REFERER'] echo
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Thu Nov 21 19:53:48 GMT 2024

Total time taken to generate the page: 0.05233 seconds