How to use field value as class? Drupal 7 Not sure that is the best title...

I want add a field to a content type eg. Priority. My preference would be to make this a taxonomy reference (with Autocomplete term widget (tagging)).

Then probably through a preprocess I would like to add any terms entered as classes to the node (in particular when a teaser but that's not important).

I am not the world's greatest php coder and apologise if this doesn't make a great deal of sense. I have been banging my head against the wall for three days now and any help would be greatly appreciated :) 

I gather it has something to do with MYTHEME_preprocess_node and $variables['classes_array'][], but I don't seem to be able to put my finger on it.
This should be a start.

function mytheme_preprocess_node (&amp;$variables)
{
  $node = $variables["node"];

  if (isset($node-&gt;field_foo["und"][0]["taxonomy_term"])) {
    foreach ($node-&gt;field_foo["und"] as $foo) {
      $term = $foo["taxonomy_term"];
      $variables["classes_array"][] = "term-" . str_replace(" ", "-", strtolower($term-&gt;name));
    }
  }
}


Note, this is barely tested  and your exact situation may vary.  It assumes field_foo is the machine name for your taxonomy reference, and your theme is flattening $variables["classes_array"] for use in node.tpl.php.