A useful bit of code from Harri Bell-Thomas you can use to dynamically create WordPress Page Templates with PHP.