how can i add a subterm of taxonomy in code $vocabulary = (object) array(
'name' =&gt; st('A'),
'description' =&gt; st('A'),
'machine_name' =&gt; 'user_a',
'help' =&gt; 'test for subterm',
);
taxonomy_vocabulary_save($vocabulary);

$user_a=array(st('A'),st('B'));

$user_a_vid=db_select('taxonomy_vocabulary', 'tv')
  -&gt;fields('tv', array('vid'))
  -&gt;condition('machine_name', 'user_a')
  -&gt;execute()
  -&gt;fetchField();

foreach ($user_a as $name) {
    $term = new stdClass;
    $term-&gt;name = $name;
    $term-&gt;vid = $user_a_vid;
    taxonomy_term_save($term);
 }


i have two vocabulary A and B

and i want to add sub-term of A and B

A have sub-term 1,2
B have sub-term 3,4

how can i do that in code?

Thanks for reading my question~thx~
Yeh~

i found out,this code can fix all the problem

$term-&gt;parent = $parent_tid;