can't understand a function

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
everydayrun
Forum Commoner
Posts: 51
Joined: Wed Jan 20, 2010 1:30 am

can't understand a function

Post by everydayrun »

Code: Select all


function garland_separate_terms($node_taxonomy) {
if ($node_taxonomy) {
//separating terms by vocabularies
foreach ($node_taxonomy AS $term) {
     $links[$term->vid]['taxonomy_term_'. $term->tid] = array(
           'title' => $term->name,
           'href' => taxonomy_term_path($term),
           'attributes' => array(
                         'rel' => 'tag',
                         'title' => strip_tags($term->description)
                         ),
         );
}
//theming terms out
foreach ($links AS $key => $vid) {
   $terms[$key] = theme_links($vid);
}
}
return $terms;
}

the above is a self defined function, i couldn't understand it, first, i don't know why the author didn't do this $node_taxonomy = array();
InsanityNet
Forum Newbie
Posts: 6
Joined: Mon Oct 25, 2010 12:37 pm

Re: can't understand a function

Post by InsanityNet »

Can you provide as to what context it is used? There is not much info in the function itself
User avatar
twinedev
Forum Regular
Posts: 984
Joined: Tue Sep 28, 2010 11:41 am
Location: Columbus, Ohio

Re: can't understand a function

Post by twinedev »

I found the function here earlier:

http://timonweb.com/how-to-separate-dru ... vocabulary

I was wondering if you meant "why the author didn't do this $links = array();" since the $node_taxonomy is being populated by the call to the function.

-Greg
Post Reply