title: How can I check if a string is in an array without iterating over the elements?
body: <p>Is there a way of checking if a string exists in an array of strings - without iterating through the array?</p>
  
  <p>For example, given the script below, how I can correctly implement it to test if the value stored in variable $test exists in $array?</p>
  
  <pre><code>array=('hello' 'world' 'my' 'name' 'is' 'perseus')
  
  #pseudo code
  $test='henry'
  if [$array[$test]]
     then
        do something
     else
        something else
  fi
  </code></pre>
  
  <p><strong>Note</strong></p>
  
  <p>I am using bash 4.1.5</p>