How can I do so many doors without using a function for each one?

I mean, I dont want to do this:

PHP Code:
main()
{
thread door1();
thread door2();
thread door3();
}

door1()
{
... 
I want to make like a script which allows you to open every door, instead of using a new function for each one. I know this because I've seen in jm_cruise map. I also know that I must use arrays, but it's a bit hard for me

Can you help me? Any help will be appreciated <3