I'm trying to save a multiline string, something like this in plain text:
define host {
use template;
host_name $host_name;
address 46.224.2.220;
contacts $email;
}
but variables e.g. $host_name and $email must be replaced with their values. s
I couldn't figure this out. any way to achieve this?
You can use str_replace
$plain_text = "define host {
use template;
host_name $host_name;
address 46.224.2.220;
contacts $email;
}";
$find = array("$host_name", "$email");
$replace = array($host_name, $email);
$new_plain_text = str_replace($find, $replace, $plain_text);