Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 388993
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T15:49:24+00:00 2026-05-12T15:49:24+00:00

PHP provides associative arrays but there is no such thing in classical asp. I

  • 0

PHP provides associative arrays but there is no such thing in classical asp. I am looking for a class or function that allows me to create and traverse a hierarchy similar to this:

United States
  Washington
    Electric City
      Banks Lake 
    Lake Chelan
      Wapato Point 
    Gig Harbour
Mexico
  Nayarit
    Aticama
Asia
  India
    Mumbai
  Pakistan
    Sindh
      Karachi

As you can notice, the hierarchy has uneven depth — it could be 3, 4 or 5 levels deep. The database structure is even more complicated as for some records I have to start displaying data from region level while for others I should start from country. An array of arrays would really help but in ASP my hands are tied.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T15:49:24+00:00Added an answer on May 12, 2026 at 3:49 pm

    Its tempting to advise you to use JScript on the server side instead of VBScript. Not only does it do this sort of thing more naturally, you are likely to be familiar with the language. The downside is that the vast majority of “How-To” on the Web related to ASP is written in VBScript.

    The associative array in VBScript is called the Dictionary is available from the Scripting library. However to create a heirarchical structure you will probably need a little more help. I would create a class around the Dictionary so that I can hold more that just a Name property and to make heirarchical manipulation easier.

    Here is a sample class:-

    Class Node
       Private myName
       Private myChildren
    
       Private Sub Class_Initialize()
         Set myChildren =  CreateObject("Scripting.Dictionary")
       End Sub
    
       Public Property Get Name()
          Name = myName
       End Property
    
       Public Property Let Name(value)
          myName = Value
       End Property
    
       Public Function AddChild(value)
    
         If Not IsObject(value) Then
           Set AddChild = new Node
           AddChild.Name = value
         Else
           Set AddChild = value
         End If
    
         myChildren.Add AddChild.Name, AddChild
    
       End Function
    
    
       Public Default Property Get Child(name)
         Set Child = ObjectOrNothing(myChildren.Item(name))
       End Property
    
       Public Property Get Children()
         Set Children = myChildren
       End Property
    
       Private Function ObjectOrNothing(value)
         If IsObject(value) Then
           Set ObjectOrNothing = value
         Else
           Set ObjectOrNothing = Nothing
         End If
       End Function
    
    End Class
    

    Now you can create your tree:-

     Dim root : Set root = new Node
     With root.AddChild("United States")
       With .AddChild("Washington")
         With .AddChild("Electric City")
           .AddChild "Banks Lake"
         End With
         With .AddChild("Lake Chelan")
           .AddChild "Wapato Point"
         End With
         .AddChild "Gig Harbour" 
       End With
     End With
    

    Now access this heirarchy as:-

    Sub WriteChildrenToResponse(node)
      For Each key In node.Children
    
        Response.Write "<div class=""node"">" & vbCrLf
        Response.Write "<div>" & root.Child(key).Name "</div>" & vbCrlF
        Response.Write "<div class=""children"">" & vbCrLf
    
        WriteChildrenToResponse root.Child(key)
    
        Response.Write "</div></div>"
      Next
    End Sub
    
    ''# Dump content of root heirarchy to the response
    WriteChildrenToResponse root
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any class for PHP 5.3 that provides RSA encryption/decryption without padding? I've
PHP provides a mechanism to register a shutdown function: register_shutdown_function('shutdown_func'); The problem is that
I am looking for a really simple PHP image gallery system that allows file
I'm trying to create a generic class in PHP that will provide a way
I'm trying to create a secure webservice (that provides simple database data) with PHP
I have two arrays of values that I would like to combine - but
I'm using namespaces in PHP for the first time in an application that provides
I am currently displaying date/time on my webpage using the date function PHP provides.
Code in inc/q/prof.php: <?php // Insert Comments into Database that user provides $comm =
I am looking for an equivalent to the php.net manual ( https://www.php.net/manual/en/ ) but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.