使用if语句嵌套PHP

I have some PHP code

<div class="pod-b footer-pod">
            <h3 class="footer-title">Our Contacts</h3>
            <?php   
            $teachers = tribe_get_organizers_custom();  
            ?>

                <?php foreach ($teachers as $teacher){

                    // vars
                    $id = $teacher -> ID;
                    $title = $teacher -> post_title;
                    $yogaName = get_field('yoga_name', $id);
                    $phone = tribe_get_organizer_phone($id);
                    $email = tribe_get_organizer_email($id);
                ?>
    <?php
    if (!get_field('hide_the_teacher_bio_on_this_event')) {

        <div class="teacher id_<?php echo $id; ?>">
                        <h4 class="teacher-name"><?php if($yogaName){echo $yogaName;}else{echo $title;}  ?></h4>
                        <div class="teacher-phone"><i class="ion-android-call"></i><?php echo $phone;  ?></div>
                        <div class="teacher-email"><i class="ion-ios-email"></i><a href="mailto:<?php echo $email;  ?>"><!--<?php echo $email;  ?>-->Email me</a></div> 
                    </div>

                }?>
        </div>

(updated) - I am trying to wrap the div with the class of "teacher (id)" in an if statement - but am getting the openign and closing PHP syntax wrong somehow.

Any help much appreciated, thank in advance!

Are you trying to print one record or a bunch of records? Your usage of a for loop suggests that you are trying to print a set of values for each teacher.

There are a number of ways of making this work.

a) The quick and dirty way: Wrap your entire HTML content and echo it by iterating through the values.

Eg: for each ($teachers as $keyteacher => $valueteacher) {
$yoganame = get_field('yoga_name',$valueteacher['id']);
if ($yoganame != "") {
echo "<div class=techer_id_$valueteacher['id']...... so on and so forth"
  }
}

b) The preferred way (how I would do it) is to return the values as an array and use jQuery / javascript to write out the HTML elements.

Thank for your reply - I worked out the problem, it was just that I hadn't closed my PHP tag before the HTML block started - doh! Thanks anyway ;)