php explode / split - 在单个脚本中共存

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.

A better option in the short term is to disable the warning until you're able to upgrade your PHP version.

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.

If explode doesnt exist, create it

if (!function_exists('explode')) { 
   function explode($str, $array) {
      return split($str, $array); 
   }
}

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);}