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)

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

${table[$var]}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.