Get data from dropdown and update page

How about this:

<?php

$arr = ["Cat", "Dog", "Cow" ];


if( $_POST['animal']){
   $animal=$_POST['animal'];
   echo $animal;    

}


?>

<form name="f" id="a" method="post" action="">
<select id="animal" name="animal" onchange="this.form.submit()" >                      
  <option value="0">--Select Animal--</option>
  <?php

   foreach ($arr as $a){

    if($a == $animal){
        echo "<option value="{$a}" selected >$a</option>";
    }else{
        echo "<option value="{$a}" >$a</option>";
    }

   }

   ?>

</select>
</form>

Note you may also unset the variable at the end but garbage collector is also there in PHP. This code assumes you use at least PHP 5.4+, else define te array via $arr = array("Cat", "Dog", "Cow" );