3v4l.org

run code in 300+ PHP versions simultaneously
<?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);

preferences:
25.33 ms | 404 KiB | 5 Q