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
Post a Comment