I'm in a pickle where I have the following set of lines:
John Smith
John Smith +1
John Smith (drink)
John Smith ( drink )
John Smith, drink
John Smith , drink
John Smith +1 , drink
John Smith +1 (drink)
John Smith +1, drink
John Smith +1 drink
What I need to do is get them into an array like
'array' =>
'name' => 'John Smith',
'plus' => '',
'comment' => ''
,
'array' =>
'name' => 'John Smith',
'plus' => '+1',
'comment' => ''
,
'array' =>
'name' => 'John Smith',
'plus' => '',
'comment' => 'drink'
and so on ... which seems like I need some Google level regex-es here. I so far explode the entire .txt file with \n
and foreach
the lines and then explode by space
and but then I just find myself in the middle of a hell of a mess. So if anyone has any better ideas on how to do so, I would kill for that knowledge. Any help is appreciated. By any I mean any kind that at all.