将格式化文本块转换为PHP数组

So I have a block of text which I wish to convert into a PHP array. The end goal is to enter over 40 years worth of data into MySQL database as quickly as possible.

(1) FRANK SINATRA – Strangers In The Night (and charts)
(4) THE MERSEYS – Sorrow
(19)    PAUL & BARRY RYAN – I Love Her
(NEW)   EDDY ARNOLD – I Want To Go With You

So ideally, if the data could be parsed into the following arrays so I can process the data. Any ideas how to do this? I did think of using preg_split. Does anyone else have any ideas?

$chartpos[] = "1"
$artist[] = "FRANK SINATRA"
$track[] = "Strangers In The Night"
$performancetype[] = "and charts"`

This regular expression would get you an array at $matches with an 'id' element and a 'name' element containing all the corresponding position if i understood your format correctly

$a = "(1) FRANK SINATRA – Strangers In The Night (and charts)
(4) THE MERSEYS – Sorrow
(19)    PAUL & BARRY RYAN – I Love Her
(NEW)   EDDY ARNOLD – I Want To Go With You";

preg_match_all('/\((?<id>[0-9]|NEW)\) (?<name>.*)/', $a, $matches);
print_r($matches);

This will help you...

$re = '/\(([0-9NEW]+)\)\s+([A-Z& ]+) – (.*)/m';
$str = '(1) FRANK SINATRA – Strangers In The Night (and charts)
(4) THE MERSEYS – Sorrow
(19)    PAUL & BARRY RYAN – I Love Her
(NEW)   EDDY ARNOLD – I Want To Go With You';

preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0);

// Print the entire match result
var_dump($matches);