finalized function to create php config files from array structures