Quantcast
Channel: Remove any comma before or after a string? - Stack Overflow
Browsing all 3 articles
Browse latest View live

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 Article



Answer 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 Article

Remove 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
Browsing all 3 articles
Browse latest View live




Latest Images