Remove a comma at the end
-
Hello,
I use a function to extract my tag of post on single page to put them in my meta keywords, unfortunately, this function create an undesired comma at the end(see after tag4), so I have a result like on this example :
<meta name="keywords" content="tag1,tag2,tag3,tag4,"/>
And I want a result like this :
<meta name="keywords" content="tag1,tag2,tag3,tag4"/>
Someone could tell me what I need to change in my function to have this result please ?
Here’s my function :
<?php function extract_tags() { global $post; $the_tags =''; if(get_the_tags($post->ID)){ foreach(get_the_tags($post->ID) as $tag) { echo $stuff[] = $tag->name . ','; } } return $stuff; } ?>
- The topic ‘Remove a comma at the end’ is closed to new replies.