Created
May 24, 2023 17:22
-
-
Save Shoora/abd29828746ac624eba0b49756f21df3 to your computer and use it in GitHub Desktop.
Замена любых символов в строке на любые другие
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Замена любых символов в строке на любые другие | |
* | |
* @param [string] $string - входная строка | |
* @param [string] $a - что поменять | |
* @param [string] $b - на что поменять | |
* @return string - строка с замененными символами | |
*/ | |
function simbols_to_simbols($string, $a, $b) { | |
$array = explode($a, $string); | |
return implode($b, $array); | |
} | |
$string = "Я смотрю ты за себя взялся, курить бросил, по утрам бегаешь... Никак до пенсии решил дожить?"; | |
echo simbols_to_simbols($string, " ", "_"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment