在PHP中检查参数类

At the moment, I have the following:

<?php if ($custom != ""): ?> 
    <div class="head-row5" id="custom">
        <?php print $custom?>                    
    </div><?php //head-row5 ?>                  
<?php endif; ?>

What is returned is something like....

<div class="block block-block" id="block-block-15">
    <div class="title">
        <h3></h3>
    </div>
    <div class="content"><p style="text-align: center;"><a href="website linkage" id="T2roll"><span class="alt">Name of the linked page</span></a></p>
</div>

What I'm trying to do is find a way to print this out ONLY if the <span class="alt"> is true.

How would I go about doing this?

I believe that I'm going to have to check the elements by class of this $custom parameter. However, I have no idea how to go about doing this.

function mytheme_preprocess_block(&$vars) {
  if ($vars['block_id'] === 'target_block_id') {
    // do something for this block

  }
}