We Recommend

Wicked Cool PHP: Real-World Scripts That Solve Difficult Problems Wicked Cool PHP: Real-World Scripts That Solve Difficult Problems
Wicked Cool PHP contains a wide variety of scripts to process credit cards, check the validity of email addresses, template HTML, and serve dynamic images and text.


Posted By

WimLeers on 11/01/07


Tagged

drupal taxonomy


Versions (?)


Who likes this?

1 person has marked this snippet as a favorite

unravelme1


vocabulary to options


Published in: PHP 


  1. function vocabulary_to_options($vid) {
  2. $tree = taxonomy_get_tree($vid);
  3. if ($tree) {
  4. foreach ($tree as $term) {
  5. $choice = new stdClass();
  6. $choice->option = array($term->tid => str_repeat('-', $term->depth) . $term->name);
  7. $options[] = $choice;
  8. }
  9. }
  10. return $options;
  11. }

Report this snippet 

You need to login to post a comment.