I need to phrase php strings and "explode" it into 3 variables based on a template.
I tried doing it using the explode
function, however it's a little messy.
list($name, $role) = explode(' (', $value);
list($firstName, $lastName) = explode(' ', $name);
For example, I have these strings:
$str_1 = "Jane Joe (Team 1)";
$str_2 = "John Joe (Bank)";
I need to extract first_name
, last_name
and the role
, which is the string in the parentheses.
I also tried regular expressions, but I'm a little rusty with regular expressions