Add last class to WordPress Footer Widget

This function adds a “last” class to the last footer widget.

/* Add dynamic_sidebar_params filter */

/* Register our callback function */
function footer_widgets($params) {	 

     global $footer_widget_num; //Our widget counter variable

     //Check if we are displaying "Footer Sidebar"
      if(isset($params[0]['id']) && $params[0]['id'] == 'footer_sidebar'){
	 $divider = 3; //This is number of widgets that should fit in one row		

         //If it's third widget, add last class to it
         if($footer_widget_num % $divider == 0){
	    $class = 'class="last '; 
	    $params[0]['before_widget'] = str_replace('class="', $class, $params[0]['before_widget']);


      return $params;