I am trying to get the actual variable name and pass it as a string, trying and cut out some work on a form processor script, I could either use two str_replace() nested or simpler just hand code the variable names into the strings, but rather than doing that I want to try and make it quick and simple to edit so if I added other form values it would be a simple copy paste on the block of code for that form element value and then quickly copy and past the additional variable name without having to stop and actually type the variable name where it is passed to build_content()... again also trying to cut down on code doing away with using str_replace() twice on each value:
Code: Select all
if (!is_badword($first_name, $fBadwords)) {
$messageContent .= build_content($first_name, str_replace('$', '', str_replace('_', '', '$first_name')));
} else ...
or just as:
Code: Select all
if (!is_badword($first_name, $fBadwords)) {
$messageContentStr .= build_content($first_name, 'First name');
} else ...
Code: Select all
<?php
print ($messageContentStr);
//Would output:
First name: Persons name
?>
The function buildContent() just builds the string for the body of the email for the name and content of each value passed to it.
Ideally it could just use:
Code: Select all
$messageContentStr .= buildContent($first_name);
and have the following
output:
First name: Persons name