在PHP中使用模板系统来获取doc类型

I have lots of docx and doc files in a particular folder.

Lets suppose i have tc.doc file in which following is content

This is certified that student_name S/o father_name is a student of this school and have following address

Now i have a list of students. if i print a document for particular student i need this data in doc file or it may create new file

This is certified that Rajat S/o Mr. abc s a student of this school and have following some addresss

Rajat / abc and some addresss is in database. Can anybody tell me how to handle this?

I don't know where to start

Thanks a lot