Jump to content

Can anyone solve this error: Deprecated: Function split() is deprecated


Function

Recommended Posts

Would anyone have the answer to solve this error message?

 

Deprecated: Function split() is deprecated in /includes/modules/shipping/table.php on line 57

 

Here is the code. Line 57 is in Bold. Preg_split is suppose to work. Tried preg_explode but that didn't work. Appreciate any help!

 

    $table_cost = preg_split("/[:,]/" , MODULE_SHIPPING_TABLE_COST);

      $size = sizeof($table_cost);

      for ($i=0, $n=$size; $i<$n; $i+=2) {

        if ($order_total <= $table_cost[$i]) {

          $shipping = $table_cost[$i+1];

          break;

        }

      }

Split() is deprecated, which doesn't mean it's unavailable.  It means it's officially not recommended to use it, and sometime in the future it will be removed entirely from the language.

 

Split accepted a regular expression, which preg_split accepts.  What are you trying to do?  The first line of your code segment should split the constant MODULE_SHIPPING_TABLE_COST on a comma or colon.  If you need to split only on a single character or non-variant string, explode() is orders of magnitude faster.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.