I have a textblock which I've exploded into lines, e.g.:
$lines = explode("\n", $textblock);
print_r($lines);
Array
(
[0] => name surname maybe a middle name (team) something else
[1] => (age) something else
[2] => etc etc
)
I want to extract name, team and age. To do that I have exploded the strings using brackets as the delimiter but it seems longwinded:
$split_name_team = explode('(', $lines[0]);
$name = $split_name_team[0];
$team = $split_name_team[1];
Then do the same thing basically to get the age:
$split_age = explode('(',$lines[1]);
$age = $split_age[1];
This all works ok, but I feel like I'm repeating a bit already. Is there a faster better way?