I have a small bunch of variables like $toAddress and $toName and want to create the variables $toAddress_Error and $toName_Error etc. for each of them if there is an error (in this case if they are empty).
Is there a way to do this in one go, eliminating the need for the 2nd line in the if statement?
if (empty($$field))
{
$errorFound = true ;
$errorVariable = $field.'_Error' ; // <<<----- how can I delete this line???
$$errorVariable = "Error: Please enter your ".$formErrors[$key] ;
}