将原始数据字符串从文本文件处理为CSV文件

I have a text file full of hundreds of lines of raw data. The data has no specific form of separation, but I know what each part refers to. For example:

316smithjohn112007

316 is the ID of that user, smith is the surname, john is the forename, 11 is the floor, and 2007 is the extension number.

What I now need to do is pull all that data into one CSV file, with the correct columns and the data separate. It needs to be a PHP script which I can run whenever an updated CSV is needed.

So for example:

ID,surname,forename,floor,ext
316,smith,john,11,2007

Hoping someone can help.

Just do a loop for each line and try to figure out what you should do. You could split the Numbers but not the names. PHP dont know what are first and lastnames.