Item is not a stdClass object
Dirp! Yes, $item is an object
No need to call JFilterOutput::stringURLSafe() more than once
Check for empty tags array before proceeding