<?php $text = "Hello {first_name}, from {company}. This is your email address: {email}. Your application for {team} has been approved."; $placeholders = ["company" => "contoso inc", "name" => "john doe", "email" => "me@contoso.com"]; echo preg_replace_callback('/\s*\{([^{}}]*)\}/', function ($match) use ($placeholders) { return isset($placeholders[$match[1]]) ? " " . $placeholders[$match[1]] : ""; }, $text);
You have javascript disabled. You will not be able to edit any code.