Undefined Function : array_combine

rlnorthcutt - April 20, 2008 - 07:06
Project:Case Tracker Work
Version:5.x-0.1-alpha
Component:Code
Category:bug report
Priority:critical
Assigned:Unassigned
Status:active
Description

I got an error because of the array_combine function, which is in PHP5 but not not in PHP4. In searching about, I found some code to correct for this and it appears to work fine. I simple added it to the top of the casetracker_work.module file:

if(!function_exists('array_combine')){
  function array_combine($keys, $values){
    if(count($keys) < 1 || count($keys) != count($values) || !is_array($keys) || !is_array($values)){
      return false;
    }

    $keys = array_values($keys);
    $values = array_values($values);
    for($x=0; $x < count($keys); $x++){
      $return_array[$keys[$x]] = $values[$x];
    }

    return $return_array;
  }
}

Ron

 
 

Drupal is a registered trademark of Dries Buytaert.