How can I trim all strings in an Array?
If I have this array:
array(" hey ", "bla ", " test");
and I want to trim all of them, How can I do that?
The array after the trim:
array("hey", "bla", "test");
How can I explode and trim whitespace?
For example, I would like to create an array from the elements in this string:
$str = 'red, green, blue ,orange';
I know you can explode and loop through them and trim:
$arr = explode(',', $str);
foreach ($arr as $value) {
$…
Php how to remove any last commas
Example output
1. test,test,test,test,test,
2. test,test,test,,
3. test,test,,,
4. test,,,,,
I tried use implode according to my previous question but It's trim only last comma.
How to remove any last commas?