How would i write a function to accept X number of parameters

for ex if i want to write a function to insert into a db. i dont know how many fields i will be inserting into the table?

just use an array to do this.


$data = array ('name'=>'john doe', 'department' => 'sales', 'age'=> 39);

function insert_record($data)
   $sql = 'insert into companytable ';
   foreach($data as $field=>$value)
      //build sql here
      $sql .= do stuff here
  //execute sql command