hierarchical select to display taxonomy tree
ASSIGN $child to an select list just set taxonomy id :
$taxonomy_vid = 3;
   /*** A HEADACHE CODE :p arrange the parent child taxonomies****/     
 /*      $tree_type =  taxonomy_get_tree($taxonomy_vid);   // taxonomy id here
    $childs["selected"]="Select a Value";
    //$childs[45]="New Launches/Projects";
    foreach($tree_type as $key =&gt;$value) {  
$temp_ = taxonomy_term_load($value-&gt;parents[0]);       //IF parent is set already
                if($value-&gt;parents[0]==0) {                   //if no any parent taxonomy
                        if(is_object($temp_)==TRUE) {
                        if(isset($childs[$temp_-&gt;name])) {  //if array key is already set 
                                if(is_array($key)!=FALSE) { //if value is not an array
                                    $childs[$temp_-&gt;name][$key]=array($key=&gt;$value-&gt;name);  // set the parent child array
                                }
                        }else {
                                if(is_array($key)!=FALSE) {    //if value is not an array
                                    $childs[$temp_-&gt;name][$key]=array($key=&gt;$value-&gt;name);  // set the parent child array
                                }
                            }
                        }else
                        {
                            $childs[$value-&gt;name]=array();
                            $childs[$value-&gt;name][$key]=$value-&gt;name;
                            //drupal_set_message("-------&lt;pre&gt;".$value-&gt;name."&lt;/pre&gt;-------");
                            }
                    }else {
                        //$temp_ = taxonomy_term_load($value-&gt;parents[0]); //IF parent is set already
                        $childs[$temp_-&gt;name][$key]=$value-&gt;name;       //$childs[$temp_-&gt;tid]=$temp_-&gt;name;
                    }
        }