placeholder in an article
2 posts by 2 authors in: Forums > CMS Builder
Last Post: November 6, 2020 (RSS)
By petrogus - November 6, 2020
Hello to all,
I am looking for solution about a placeholder in an article. I would like to insert dynamic a names or address in a GDPR agreement.
Have anyone idea how can do it. For example see below.
Textfield : #placeholder-name
Textbox : #placeholder-address
Field box : #placeholder-phonenumber
"Lorem ipsum dolor sit amet, #placeholder-name consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation. Duis aute irure dolor in #placeholder-address reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
Excepteur sint occaecat cupidatat non proident, #placeholder-phonenumber sunt in culpa qui officia deserunt mollit anim id est laborum."
thank you in advance !
By Dave - November 6, 2020
Hi petrogus,
You could try something like this:
$str = "Hello #location# today is #weekday#!";
$str = replacePlaceholders($str);
print $str;
exit;
function replacePlaceholders($text) {
$placeholders = [];
$placeholders['location'] = "World";
$placeholders['weekday'] = "Friday";
foreach ($placeholders as $key => $value) {
$text = str_replace("#$key#", $value, $text);
}
return $text;
}
Hope that helps!
interactivetools.com