asp function for each

Thread Starter

chandrasekhar

Joined Nov 5, 2010
13
<%
Response.Cookies("firstname")="Alex"
Response.Cookies("user")("firstname")="John"
Response.Cookies("user")("lastname")="Smith"
Response.Cookies("user")("country")="Norway"
Response.Cookies("user")("age")="25"
%>


<html>
<body>

<%
dim x,y
for each x in Request.Cookies
response.write("<p>")
if Request.Cookies(x).HasKeys then
for each y in Request.Cookies(x)
response.write(x & ":" & y & "=" & Request.Cookies(x)(y))
response.write("<br />")
next
else
Response.Write(x & "=" & Request.Cookies(x) & "<br />")
end if
response.write "</p>"
next
%>

</body>
</html>


what is the use of "for each function in the above program.
plz explain in detail:D
 

Papabravo

Joined Feb 24, 2006
22,082
It is a looping construct. Instead of using an index to select elements of an array the foreach construct assumes that the details of the structure and the number of elements are well known and so a loop index would be superfluous.
 
Top