IT SOLUTIONS
Your full service technology partner! 
-Collapse +Expand
To/From Code
-Collapse +Expand Cross Ref Guide
-Collapse +Expand Members-Only
Sign in to see member-only pages.
   ► KBTo/From GuidesASP ClassicData Structures  Print This     

Associative Array (Cross Ref > Data Structures)

By Mike Prestwood

ASP Classic versus PHP: A side by side comparison between ASP Classic and PHP.

 
Data Structures
 

Data structures allow you to store and work with data. Common data structures include arrays, associative arrays, etc.

Associative Array

[Other Languages] 
A set of unique keys linked to a set of values. Each unique key is associated with a value. Think of it as a two column table. MyArray['CA'] = 'California' MyArray['AR'] = 'Arizona'

Languages Focus

Associative arrays are also known as a dictionary or a hash table in other languages.

ASP Classic:   Scripting.Dictionary

Use the scriptiing dictionary object which is available on later versions of ASP Classic (all still commonly in use).

Note: Both Access VBA and VB Classic use a collection for this but collections are not supported in ASP Classic.

Syntax Example:
Dim StateList
 
set StateList = Server.CreateObject("Scripting.Dictionary")
StateList.Add "CA", "California"
StateList.Add "NV", "Nevada"
 
Response.Write "I live in " & StateList.Item("CA")
PHP: 

Declare associative array with initial known values. You can also add to associative array. (You can just assign values without ever declaring it too!)

Syntax Example:
$prices = array( 'Tires'=>100, 'Spark Plugs'=>4 );
$prices['Oil'] = 10;
 
echo "Tires=" . $prices['Tires'] . "<br>";
echo "Oil=" . $prices['Oil'] . "<br>";












Sales Website: www.prestwood.com Or visit our legacy sales site: 
legacy.prestwood.com


©1995-2024 Prestwood IT Solutions.   [Security & Privacy]