Alternative-WXSIM-Display 'Deprecated split()' Problem

This notice pops up on my wsWxSim Saratoga templated display frequently:
Deprecated: Function split() is deprecated in /home/content/58/7474958/html/wsWxsim/plaintext-parser.php on line 453
despite the fact that no such php function call is present in ANY of the scripts in this display (I searched for ‘split(’ in all files in my /wsWxsim folder.) I found plenty of javascript ‘.split(’ entries, and there is a ‘preg_split()’ close by in line 448 of ‘plaintext.parser.php’, but no ‘split()’ function can be found. Here are lines 437-459 of the code that keeps getting flagged without cause:

if (preg_match('|WXSIM text forecast for (.*), initialized at\s+(.*)|i',$plaintext,$matches)) {
  $WXSIMcity = PPget_lang(trim($matches[1]));
  $wdate = trim($matches[2]);
  $Status .= "<!-- wdate '$wdate' -->\n";
  // there are LOTS of formats of the date stamp in plaintext.txt
  // 012345678901234567890
  // 20:00   Feb 21, 2007
  // 15:00   02 Apr, 2007
  // 8:00 PM Mar 24, 2007
  // 12:00 AM 24 Mar, 2007
  // 17:00Z  05 Nov, 2007
  $wdateParts =  preg_split("/[\s,]+/", $wdate);
//  $Status .= "<!-- wdate split\n" . print_r($wdateParts,true) . " -->\n";
  $i=0;
  if (preg_match('!AM|PM!i',$wdateParts[1]) ) { // got US style date.
    list($wHrs,$wMins) = explode(':',$wdateParts[0]);
	if (strtolower($wdateParts[1]) == 'pm' and $wHrs <> 12 ) {$wHrs += 12; }
	if (strtolower($wdateParts[1]) == 'am' and $wHrs == 12 ) {$wHrs = '00'; }
    $wTime = "$wHrs:$wMins";
	$i=1;
  } else {
    $wTime = $wdateParts[0];
  }

Reloading the page will then display the page without the ‘Deprecated:’ notice.

Does anyone have any idea why this is happening?


I think, from what i have read on this splt malarky you have to change all the splts to explode

The reason it only shows sometimes: When new data is uploaded from wxsim, this new data is processed (hence the errors) and saved into a cache file so new requests for the same data are faster. Until there is new data uploaded the error messages will therefor not appear as the pre-processed data from the cache is used.

The split is in your current source line 453 www.gwwilkins.org/wsWxsim/plaintext-parser.php?sce=view

//  $Status .= "<!-- wdate split\n" . print_r($wdateParts,true) . " -->\n";
  $i=0;
  if (preg_match('!AM|PM!i',$wdateParts[1]) ) { // got US style date.
    list($wHrs,$wMins) = split(':',$wdateParts[0]);
	if (strtolower($wdateParts[1]) == 'pm' and $wHrs <> 12 ) {$wHrs += 12; }
	if (strtolower($wdateParts[1]) == 'am' and $wHrs == 12 ) {$wHrs = '00'; }
    $wTime = "$wHrs:$wMins";
	$i=1;

So maybe there are multiple versions but it is realy there!

Solution 1. copy the version you displayed in your post (with explode at 453 ) to the one with the error

Solution 2. Support site http://leuven-template.eu/problems.php?lang=en
==> choose problems
==> 2015-04-12 plaintext-parser.php notice messages, depreciated ereg.
Make as always a backup/copy of the script just to be sure.
There are many versions out there and the split was removed some time agao. This new version also removes the depreciated ereg function but i am not sure that it is compatible with your version.

Solution 3. These messages appear as your are now using a more recent version of PHP at your webserver.
It is not a warning or an error, only a message to the programmer to do something about it as in future releases these functions will not be available anymore.
You could set the error reporting to ~notice to remove these messages also.

Wim

Thanks, Wim. I saw that ‘split’, but I didn’t think it was a function call. Live and learn. I’ll change it to explode and see what happens.

I appreciate the help! :slight_smile: