Reputation: 2527
I have php two servers with different versions of php, and am having trouble with split statement which seems to be deprecated on new box. I replaced with explode which is not known to old box.
$connect = explode(";", DB_CONNECT);
$connect = split(";", DB_CONNECT);
what statement(s) will make both servers happy? Upgrading is not an option tonight.
Upvotes: 0
Views: 207
Reputation: 1751
I have not tried this but hopefully it will work. Good luck.
function ultraExplode($del,$arr){
$ver=phpversion();
if ($ver>=5) return explode($del,$arr);
else return split($del,$arr);}
Upvotes: 0
Reputation: 2724
If explode doesnt exist, create it
if (!function_exists('explode')) {
function explode($str, $array) {
return split($str, $array);
}
}
Upvotes: 1
Reputation: 23316
A better option in the short term is to disable the warning until you're able to upgrade your PHP version.
Upvotes: 1
Reputation: 27233
Try preg_split()
and preg_match_all()
. The latter doesn't return an array, but may fill in an array pass in as third argument.
Upvotes: 0