I have an multidimensional array, and i want to add if condition in array. Like :
$check = "failed";
$data = array(
"personalizations" => array(
array(
"to" => array(
array("email" => $userEmail, "name" => $userName)
),
if(strpos($check, "SUCCESS") !== false){
}else{
"CC" => array(
array("email" => $adminEmail,"name" => $adminEmail)
)
}
)
),
"from" => array("email" => $senderEmail, "name" => $senderName),
"subject" => $subject,
"content" => array(array("type" => "text/html", "value" => $body))
);
I want to send an email to the administrator. If the $subject does not have the word success, add CC array to the array, otherwise do not add cc.
I am getting error : syntax error, unexpected 'if' (T_IF), expecting ')'