How to remove the last occurrence of comma from a string in PHP

1 Answer

0 votes
$str = 'c c++, nodejs, python, php java';

$str = substr_replace($str, '', strrpos($str, ','), 1);

echo $str;




/*
run:

c c++, nodejs, python php java

*/

 



answered Apr 17, 2022 by avibootz

Related questions

1 answer 133 views
1 answer 158 views
1 answer 133 views
1 answer 143 views
2 answers 168 views
...