trying to write a proper if statement in php
<p>i am having a hard time wrapping my head around how to do this... i have a select menu i want to display as default and a different one(s) if certain items appear in a shopping cart.</p>

<p>so say i sell dogs and cars. in the cart i have selected one of each. i want one select menu to appear if there are ever any cars in the cart. but if there are ever any dogs in the cart or cats for that matter i want a different select with different options to appear. so car_select would be the default if anything is in the cart...(i sell a lot of stuff) but if a dog appears in the cart then dog_select would replace it. </p>

<p>the way it is written now. the default is the last thing and that is what shows.
(see my comments)</p>

<p>so the code:</p>

<pre><code>&lt;?php
foreach($this-&gt;rows as $i =&gt; $row){

if (strstr('dogs',$row-&gt;dates)) {
$mydates = 'dogs';
} else {$mydates='default';}


//echo $row-&gt;dates; this spits out the correct values dogcar


}
//echo $mydates; with a dog and a car in the cart this returns default
//below functions i believe but i think the above is faulty 
?&gt;
&lt;?php 
if ($mydates =='dogs'){
//do something here;} else {

    $type = $this-&gt;type;
    foreach($this-&gt;extraFields[$type] as $fieldName =&gt; $oneExtraField) {
     if ($fieldName != 'pickupdate-rosh'){; ?&gt;
        &lt;tr class="hikashop_checkout_&lt;?php echo $fieldName;?&gt;_line"&gt;
            &lt;td class="key"&gt;
                &lt;?php echo $this-&gt;fieldsClass-&gt;getFieldName($oneExtraField);?&gt;
            &lt;/td&gt;
            &lt;td&gt;
                &lt;?php 

                        echo $this-&gt;fieldsClass-&gt;display($oneExtraField,$this-&gt;$type-&gt;$fieldName,'data['.$type.']['.$fieldName.']'); 
                ?&gt;
            &lt;/td&gt;
        &lt;/tr&gt;
&lt;?php } ?&gt;
    &lt;?php } ?&gt;
&lt;?php } ?&gt;
</code></pre>

<p>i would like to always return car_select unless the presence of dogs or cats etc in the cart.
{edit: i just realized that is not the correct function to use to look for a string.}</p>
