they get assigned in the order in which the appear on the webpage.
therefore the first form on the page gets document.forms[0], the second gets document.forms[1], and so on.
so you cant really write a javascript snipped using the array indices unless you also wrote the html code and you know the person will not insert a form before yours.
just as a reference it goes the same way with images, you can have <img name="test" src="someimage.jpg">
and javascript will give document.images.test, and document.images[0]....
that is useful for doing mouse overs and stuff.
btw. i originally brought up javascript because php doesnt do anything with the form name anyway, it doesnt make it available as a variable or special array so i thought the q may have been more geared toward js.