在PHP Array中找到一个类别

this is my code

<?php 
    $portfolio_categories = get_categories(array('taxonomy'=>'portfolio_category'));
    foreach($portfolio_categories as $portfolio_category)
        echo '<li data-filter=".' .$portfolio_category->slug. '"><a href="#">' .$portfolio_category->name. '</a></li> ';
?>

this shows the filters created by the category's name inside $portfolio_categories then, there is the creation of client's list

<ul id="list" class="portfolio_list clearfix responsive">                   
    <?php
        $temp = $wp_query;
        $wp_query= null;
        $wp_query = new WP_Query( array( 'post_type' => 'portfolio', 'posts_per_page' => -1, 'orderby'=> 'title', 'order' => 'ASC' ) );
    ?>

    <?php if (have_posts()) : while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
        <?php $terms = wp_get_object_terms($post->ID, 'portfolio_category'); ?>
        <?php $pf_bimg = wp_get_attachment_url( get_post_thumbnail_id() );?>
        <?php $pf_simg = aq_resize( $pf_bimg, 420, 450, true ); ?>                          
        <li class="span3 list_item <?php foreach ($terms as $term) { echo $term->slug.' '; } ?>">
            <div class="recent-item">
                <figure>
                    <div class="touching medium">
                        <a href="<?php the_permalink(); ?>" class=""><img src="<?php echo $pf_simg; ?>" alt="<?php the_title(); ?>" /></a>
                        <!-- <a href="<?php echo $pf_bimg; ?>" class="hover-zoom mfp-image"><i class="icon-search"></i></a>
                        <a href="<?php the_permalink(); ?>" class="hover-link"><i class="icon-link"></i></a> -->
                    </div>
                    <figcaption class="item-description">
                        <h5><a href="<?php the_permalink(); ?>" class=""><?php the_title(); ?></a></h5>
                        <span><?php $i = 0; foreach ($terms as $term) { if($i)echo " / "; echo $term->name; $i=1; } ?></span>
                    </figcaption>
                </figure>
            </div>
        </li>
    <?php endwhile; ?> <?php endif; ?>
    <?php wp_reset_query();?>                            
</ul>   

What i 'm trying to do is to display a different element for every different category . I thought to insert an if condition before the tag , like this

<?php 
    $portfolio_categories = get_categories(array('taxonomy'=>'portfolio_category'));
    if ($portfolio_category = 'category1'): ?>
         <figure>1</figure>
    <?php else: ?>
         <figure>2</figure>
    <?php endif 
?>

Thank all for your time, Dan

You need to store last category, otherwise you'll have <figure> tag before each row:

<?php
    $portfolio_categories = get_categories(array('taxonomy'=>'portfolio_category'));
?>
<?php if ($portfolio_category != $prev_portfolio_category): ?>
    <?php if ($portfolio_category = 'category1'): ?>
        <figure>1</figure>
    <?php else: ?>
        <figure>2</figure>
    <?php endif; ?>
<?php endif; ?>
<?php 
    $prev_portfolio_category = $portfolio_category;
?>