I am having a function which has an array in it. I wanted to call that function foo and use the $result indexes (text, html, attachments) in my script. Please help me with this since I am totally new to php. I am trying to call the array to the mail() method. and getting error saying string expected and it id array. How can I insert the array to the relevant mail method.
function foo($a)
{
if (is_resource($b))
{
$result = array
(
'text' => null,
'html' => null,
'attachments' => array(),
);
}
return $result;
}
You cannot pass an array to the mail function as it is expecting just strings. If you want the text of the email to be $result[‘text’], try
However, it looks like what are you trying is to have an array populate the attachments and content of an email. There’s nothing like that out from the box in PHP. You may have to look for some third parties library. SwiftMailer maybe what you want.