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 through regex or anything else?
Thanks.
If you just want to remove the first and the last comma, you can use trim
$string = trim($string,",");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With