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

1 Answer

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

$ch = 'a';

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

echo $str;




/*
run:

c c++, nodejs, python, php jav c#

*/

 



answered Apr 17, 2022 by avibootz
...