Closed (fixed)
Project:
Drupal core
Version:
6.2
Component:
taxonomy.module
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
13 May 2008 at 15:15 UTC
Updated:
14 Jul 2012 at 23:32 UTC
I'm coding a block that will display all the nodes that are linked to the same term of the node that is currently rendered. I'm using this code:
$mynode = node_load(arg(1));
$results = taxonomy_select_nodes(array($mynode->taxonomy[1]->tid));
This, however, only works for nodes linked to term 1... I'm wondering why the index of the taxonomy object in that array is the same as its id and not just an incrementing index...
Can anyone tell me if this is by design, and if so, maybe a short explanation why and how I would go about to getting the first element of the array (not necessarily the element with index 1) without removing and adding it again with array_shift and array_unshift?
Comments
Comment #1
ainigma32 commentedI don't know why the index of the taxonomy array is filled with the ids of the terms but you can use
key($array)to get the key of the current array item. See here http://www.php.net/manual/en/function.key.phpTo make sure you are at the first item you can use reset: http://www.php.net/manual/en/function.reset.php
- Arie