Kelman Kelman - 4 months ago 23
PHP Question

Blankline after foreach loops

I have this foreach loop:

echo '';
foreach ($r['result']['achievements']['0']['achievements'] as $item) {
echo '
<div class="achiev-title"> ', $item['title'], '</div>
<div class="description"> ', $item['description'], '</div>

<div class="criteria">';
if(!empty($item['criteria'])){
foreach ($item['criteria'] as $item2){
echo '<li>
', $item2['description'], ' </li>';
}

}

}
echo '
</div>
<br/>';
?>


I want to have a blankline everytime the two loops are finished. For that i´ve tried the
<br/>
but without any effect.

Answer

Try This :

  echo '<div>';                
           foreach ($r['result']['achievements']['0']['achievements'] as $item) 
           {
              echo '<div class="achiev-title">'.$item['title'].'</div>
             <div class="description">'.$item['description'].'</div>

             <div class="criteria">'; 
               if(!empty($item['criteria'])) 
               {       
                  foreach ($item['criteria'] as $item2)
                  {
                    echo '<li>'.$item2['description'].'</li>';
                  }
               }
       echo '</div></br>';

         }
echo '</div>';
Comments