1.11M Members

associative arrays

 
0
 

I have an associative array named table

declare -A table
table["apple"]="fruit"
table["tomato"]="veggie"
table["highway"]="GT"
table["artist"]="eminem"

Now say I have a variable returning the value highway

How do I find corresponding value GT ??

(this value that I find (GT in this case) is supposed to be the name of a mysql table)

 
0
 

Lets say the variable contianing "highway" is "var", then

${table[$var]}
You
This article has been dead for over six months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article