- array_map: documentation ( source)
- preg_match_all: documentation ( source)
- var_export: documentation ( source)
<?php
$recipients = "john('john@yahoo.com'), frank('frank@gmail.com'),simon('simon@to.com')";
preg_match_all("/(?:, ?)?([^(]+)\('([^']+)'\)/", $recipients, $matches, PREG_SET_ORDER);
var_export(
array_map(
fn($row) => ['name' => $row[1], 'email' => $row[2]],
$matches
)
);