How to replace multiple characters in a string with other characters using PHP

1 Answer

0 votes
$str = 'php.java-cpp:::::rust-python.c.go-';

$str = str_replace('.', ' ', $str); 
$str = str_replace(':', '*', $str);
$str = str_replace('a', 'A', $str);
$str = str_replace('-', '', $str);

echo $str;


/*
run:
   
php jAvAcpp*****rustpython c go
   
*/

 



answered Oct 20, 2024 by avibootz
...