Author Topic: Function ereg_replace() is deprecated  (Read 1049 times)

0 Members and 1 Guest are viewing this topic.

Offline nineback

  • Contributor
  • ***
  • Posts: 136
    • Albertville, AL Weather
Function ereg_replace() is deprecated
« on: January 21, 2013, 09:30:24 PM »
Anyone know how to get rid of this error message:

/home/kq5s02/public_html/weather/cloud-base.php on line 1242
[22-Jan-2013 02:23:48 UTC] PHP Deprecated:  Function ereg_replace() is deprecated in

I am not sure how to write the PHP code to use, I assume, preg_replace.

Thanks.

Tom
Davis VP+
Weather Display/WeeWX
http://www.kq5s.com/

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9288
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Function ereg_replace() is deprecated
« Reply #1 on: January 22, 2013, 01:54:18 AM »
Yes, the ereg_replace() is deprecated in PHP5+

you have to use preg_replace() instead, but... it has a slightly different syntax.

Line 1242:
Code: [Select]
      $metar[1] = ereg_replace("[\n\r]+",'',$raw_metar[1]); // strip linefeeds
change to
Code: [Select]
      $metar[1] = preg_replace('|[\n\r]+|s','',$raw_metar[1]); // strip linefeeds

Change line 1274
Code: [Select]
      $page = ereg_replace("[\n\r]+",'',implode(" ",$page));
to
Code: [Select]
      $page = preg_replace('|[\n\r]+|s','',implode(" ",$page));

Change line 1280
Code: [Select]
      $metar[1] = ereg_replace("[\n\r]+",'',$raw_metar); // strip linefeeds
to
Code: [Select]
      $metar[1] = preg_replace('|[\n\r]+|s','',$raw_metar); // strip linefeeds

Best regards,
Ken
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline nineback

  • Contributor
  • ***
  • Posts: 136
    • Albertville, AL Weather
Re: Function ereg_replace() is deprecated
« Reply #2 on: January 22, 2013, 06:18:54 AM »
Thanks Ken.  I made the changes.  I knew the syntax was different and tried a few times to change it but alas I am not a PHP programmer.

Tom
Davis VP+
Weather Display/WeeWX
http://www.kq5s.com/