PHP » GoLang |
login |
register |
about
|
strtrstrtr[code]
func Strtr(str string, replace map[string]string) string {
if len(replace) == 0 || len(str) == 0 {
return str
}
for old, new := range replace {
str = strings.ReplaceAll(str, old, new)
}
return str
}
ge:
replace := make(map[string]string)
replace["Golang"] = "PHP"
fmt.Println(Strtr("Golang is the best language in the world", replace))
[/code]
|