Invoke all tags from a desired vocabulary

1:
<?php
$result = "";
$vocabulary= taxonomy_vocabulary_machine_name_load('tags');
if ($terms = taxonomy_get_tree($vocabulary->vid))
{

foreach ($terms as $term)
{

$taxonomy[] = $term->name;
$result = implode(',',$taxonomy) ;

}
return $result;

}

?>

2:
<?php

$vocabulary= taxonomy_vocabulary_machine_name_load('tags');
if ($terms = taxonomy_get_tree($vocabulary->vid))
{

$arrLength = count($terms);

for($i = 0; $i < $arrLength-1; $i++) {

echo $terms[$i]->name;

echo ',';

}

echo $terms[$arrLength-1]->name;

}

?>