I'm not using the code into a template file, like page.php. I use it in functions.php but after the function which created the taxonomy. The code works fine if the taxonomy is a standard one like "category"(which displays regular post categories) but it's not working with custom ones.

I already tried to use $option = $term['name']; but with no luck. The error I get on this one is "Undefined index: name".

Based on the error you wrote, there must be some other code that you didn't mentioned in the question & which must be causing the problem, can you add your full function to the question?
–
Mridul AggarwalNov 21 '12 at 8:48

@MridulAggarwal I`m trying to use custom taxonomies inside the admin panel. I want to generate the list of taxonomy names of a custom post type and to show them inside a meta box on wordpress pages . When someone creates a page which is using the custom template related to the custom post type, the meta box should appear with categories related to that custom post type.
–
MadalinNov 21 '12 at 9:25

What i mean is that the code currently in question is correct. The problem is due to some other nearby code. Can you add the rest of the code?
–
Mridul AggarwalNov 21 '12 at 9:46

@MridulAggarwal I suppose the code related to this issue is the one which registered the taxonomy: pastebin.com/Q0fpp7pn
–
MadalinNov 21 '12 at 9:57

nope. Either the $terms variable is being altered somewhere above foreach or the $term is being altered inside foreach, otherwise the error message would have been different.
–
Mridul AggarwalNov 21 '12 at 10:01