I get this specific string from a Mysql DB:
$string = "john('[email protected]'), frank('[email protected]'),simon('[email protected]')";
I need to have the string inserted in the following code:
$sendSmtpEmail = new \SendinBlue\Client\Model\SendSmtpEmail([
'subject' => 'Report',
'sender' => ['name' => 'sender', 'email' => '[email protected]'],
'to' => [
['name' => 'john', 'email' => '[email protected]'],
['name' => 'frank', 'email' => '[email protected]'],
['name' => 'frank', 'email' => '[email protected]']
],
'htmlContent' => $output
]);
Obviously, I need the 2d array containing associative rows in $sendSmtpEmail
, but how do I create it?
Use
preg_match_all()
to directly match one or more sequences of your formatted substrings. Use two capture groups, then map those data points to associative rows.Code: (Demo)