Remove the last character from a string
What is fastest way to remove the last character from a string?
I have a string like
I would like to remove the last ',' and get the remaining string back:
What is the fastest way to do this?
First, I try without a space,
rtrim($arraynama, ","); and get an error result.
Then I add a space and get a good result:
$newarraynama = rtrim($arraynama, ", ");
Read more... Read less...
An alternative to
substr is the following, as a function:
substr_replace($string, "", -1)
Is it the fastest? I don't know, but I'm willing to bet these alternatives are all so fast that it just doesn't matter.