<?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
)
);
- Output for 8.0.1 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.25, 8.4.1 - 8.4.12
- array (
0 =>
array (
'name' => 'john',
'email' => 'john@yahoo.com',
),
1 =>
array (
'name' => 'frank',
'email' => 'frank@gmail.com',
),
2 =>
array (
'name' => 'simon',
'email' => 'simon@to.com',
),
)
preferences:
89.63 ms | 407 KiB | 5 Q