Reputation: 1418
I have a taxonomy parent tid '8'
I need to get all child tid for this parent id
$tid = 8;
$children = taxonomy_get_children($tid);
print_r($children);
am getting this result
8
Array
(
[9] => stdClass Object
(
[tid] => 9
[vid] => 3
[name] => Domestic
[description] => Domestic
[weight] => 0
)
[12] => stdClass Object
(
[tid] => 12
[vid] => 3
[name] => Economic
[description] => Economic
[weight] => 1
)
[11] => stdClass Object
(
[tid] => 11
[vid] => 3
[name] => International
[description] =>
[weight] => 2
)
[10] => stdClass Object
(
[tid] => 10
[vid] => 3
[name] => Social
[description] =>
[weight] => 3
)
)
how can I display only tid from this array.
Upvotes: 1
Views: 2533
Reputation: 6798
$children = array_keys(taxonomy_get_children($tid));
You will notice it's an associative array where the tid in the object is the same as the array key - just grab the keys, it's equivalent to grabbing the tids from the objects themselves.
Upvotes: 4