Function Posted January 17, 2012 Share Posted January 17, 2012 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; } } Quote Link to comment https://forums.phpfreaks.com/topic/255251-can-anyone-solve-this-error-deprecated-function-split-is-deprecated/ Share on other sites More sharing options...
Stooney Posted January 17, 2012 Share Posted January 17, 2012 Try this: <?php $table_cost=explode(',', MODULE_SHIPPING_TABLE_COST); ?> Quote Link to comment https://forums.phpfreaks.com/topic/255251-can-anyone-solve-this-error-deprecated-function-split-is-deprecated/#findComment-1308725 Share on other sites More sharing options...
AyKay47 Posted January 17, 2012 Share Posted January 17, 2012 http://us.php.net/manual/en/function.split.php means in version 5.3, the function is no longer available, and shouldn't be used, you should use preg_split instead. Quote Link to comment https://forums.phpfreaks.com/topic/255251-can-anyone-solve-this-error-deprecated-function-split-is-deprecated/#findComment-1308727 Share on other sites More sharing options...
ManiacDan Posted January 17, 2012 Share Posted January 17, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/255251-can-anyone-solve-this-error-deprecated-function-split-is-deprecated/#findComment-1308735 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.