title: How to select specific value in foreach smarty?
body: <p>I am trying to get only 3 values from my array in foreach loop.I dont know how to do this.</p>
  
  <p>In drop down, now i am getting all the five values from my array.But i need to have only starting 3 values from array not 4 and 5.</p>
  
  <p>My code:-</p>
  
  <pre><code>    &lt;select class="userCountryMapSelectMetrics" style="float:right;margin-right:0;margin-bottom:5px;max-width: 9em;font-size:10px"&gt;
              {foreach from=$metrics item=metric}
                  &lt;option value="{$metric[0]}" {if $metric[0] == $defaultMetric}selected="selected"{/if}&gt;{$metric[1]}&lt;/option&gt;
              {/foreach}
          &lt;/select&gt;
  </code></pre>
  
  <p>Output:-</p>
  
  <pre><code>&lt;option value="nb_visits" selected="selected"&gt;Visits&lt;/option&gt;
  &lt;option value="nb_actions"&gt;Actions&lt;/option&gt;
  &lt;option value="nb_actions_per_visit"&gt;Actions per Visit&lt;/option&gt;
  &lt;option value="avg_time_on_site"&gt;Avg. Time on Website&lt;/option&gt;
  &lt;option value="bounce_rate"&gt;Bounce Rate&lt;/option&gt;
  </code></pre>
  
  <p>I need output to be:-</p>
  
  <pre><code>&lt;option value="nb_visits" selected="selected"&gt;Visits&lt;/option&gt;
  &lt;option value="nb_actions"&gt;Actions&lt;/option&gt;
  &lt;option value="nb_actions_per_visit"&gt;Actions per Visit&lt;/option&gt;
  </code></pre>