Answer by justhalf for Remove any comma before or after a string?
If you just want to remove the first and the last comma, you can use trim$string = trim($string,",");
View ArticleAnswer by Tim Pietzcker for Remove any comma before or after a string?
You can use anchors for this:$result = preg_replace('/^,|,$/', '', $subject);If you want to match one or more commas at the start/end of the string:$result = preg_replace('/^,+|,+$/', '', $subject);And...
View ArticleRemove any comma before or after a string?
My string is$string = ",name2,name2,name3,";I want to make it like;$string = "name2,name2,name3";That is, to remove first and last comma from that string, any clue as to how to accomplish this either...
View Article
More Pages to Explore .....