- ucwords: documentation ( source)
- in_array: documentation ( source)
<?php
function compose_mail($post) {
$ignore_fields = array('G-recaptcha-response');
$content = "Form submission: \n\n";
foreach($post as $name=>$value) {
if(!in_array($name,$ignore_fields)) {
$content .= ucwords($name).":\n";
$content .= "$value\n\n";
}
}
return $content;
}
$array = array(
'lala' => 'tralala',
'waai' => 'woei',
'G-recaptcha-response'=> 'nee'
);
echo compose_mail($array);