php - String replacement with multiple string -


i have message template need replace set of strings, example

i have message:

you have been invited [admin_name] of organization [organization_name] on [datetime]

needs replaced admin_name, organization_name, datetime

use strtr:

$text = 'you have been invited [admin_name] of organization [organization_name] on [datetime]';  $result = strtr($text, [     '[admin_name]' => 'some name',     '[organization_name]' => 'some organization',     '[datetime]' => 'some date', ]);  echo $result; 

output:

you have been invited name of organization organization on date


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -