Grouping an array in classic asp?

asp-classic, vbscript

Solution

In asp-classic there are no associative arrays ..

The alternative is the Scripting.Dictionary

so

<%
    dim ar
    ar = array(3,5,7,7,3,2,3)

    dim dictArray

    set dictArray = server.CreateObject("Scripting.Dictionary")

    for each i in ar
        if dictArray.exists( i ) then
            dictArray(i) = dictArray(i) + 1
        else
            dictArray(i) = 1
        end if
    next
%>

this has created what you want ... to see it now

<%
    for each i in dictArray
        response.write( i & " : " & dictArray(i) & "<br />")
    next
 %>

Problem

I have an array in ASP that looks like this: ``` 3,5,7,7,3,2,3 ``` What I want to do is group them together with a count so I would have: ``` Number Count 2 1 3 3 5 1 7 2 ``` Is this possible? If so how?

Original source