title: Select a variable from an array
body: <p>I am new to php arrays. I can not find the solution.</p>
  
  <p>This is my code:</p>
  
  <pre><code>$animals = Array
              (
              1=&gt;$duck,
              2=&gt;$horse,
              3=&gt;$rabbit
              );
  
              ForEach($animals As $animal) 
              {
                  echo $animals[Array_Rand($animals)];
              }
  </code></pre>
  
  <p>And now I want to select a suitable variable from the array, which is the $rabbit.</p>
  
  <p>Something like:</p>
  
  <pre><code>if($animal[3]){
                  echo 'The rabbit just spawned';
              }
  </code></pre>
  
  <p>I please, tell me how to refer to the variable number 3 (rabbit) using if instruction.</p>