Question: I'm in trouble with some php output. I'm already echoing out some html and that works fine! Those are groups that should contain more elements -> I need to output some anchor elements dynamically from the database inside each group. And that needs to happen inside the html which is already an echo. I thought I could put another foreach loop inside there...I tried and tried but I can't figure it out...I always get an error.

Dreamweaver is telling me, that this part 

```
foreach($links as $item){echo $item;}

```

is definitely wrong (syntax error), but I don't know how to put it in there correctly.

Thanks for your help!

```
echo '<li id="todo-'.$this->data['id'].'" class="todo">     
    <div class="group__name"><div class="text input_groupname">'.$this->data['text'].'</div>       
    </div>
    <div class="group_more_button">more <i class="fa fa-arrow-circle-o-down"></i></div>
    <div class="group_list_wrapper">
            <div class="group__list_SortMe">'

    '.foreach($links as $item){
        echo $item;
    }.'

               '<div class="add_button">
                  <div class="plus open">
                       <span></span>
                       <span></span>
                  </div> 
               </div> 
            </div> <!-- group__list_SortMe-->
    </div> <!-- group_list_wrapper--> 

            <div class="actions">
                <a href="#" class="edit">Edit</a>
                <a href="#" class="deleteICON">Delete</a>
            </div>

        </li>';

```

Answer: 
Or this?...just for readibility sake. I have to jump in and out of PHP to make such long strings logical to me. 

```
<li id="todo-<?=$this->data['id']?>" class="todo">     
    <div class="group__name"><div class="text input_groupname"><?=$this->data['text']?></div>       
    <div class="group_more_button">more <i class="fa fa-arrow-circle-o-down"></i></div>
    <div class="group_list_wrapper">
        <div class="group__list_SortMe">

        <?php 
        foreach($links as $item){
            echo $item;
        }
        ?>
            <div class="add_button">
                <div class="plus open">
                    <span></span>
                    <span></span>
                 </div> 
             </div> 
          </div> <!-- group__list_SortMe-->
    </div> <!-- group_list_wrapper--> 

    <div class="actions">
        <a href="#" class="edit">Edit</a>
        <a href="#" class="deleteICON">Delete</a>
    </div>
</li>

```
Below i correct your code and hope it will work fine.

```
    echo '
<li id="todo-'.$this->data['id'].'" class="todo">     
<div class="group__name"><div class="text input_groupname">'.$this->data['text'].'</div>       
</div>
<div class="group_more_button">more <i class="fa fa-arrow-circle-o-down"></i></div>
<div class="group_list_wrapper">
        <div class="group__list_SortMe">

';
foreach($links as $item){
    echo $item;
}

    echo '<div class="add_button">
                <div class="plus open">
                    <span></span>
                    <span></span>
                </div> 
            </div> 
        </div> <!-- group__list_SortMe-->
</div> <!-- group_list_wrapper--> 

        <div class="actions">
            <a href="#" class="edit">Edit</a>
            <a href="#" class="deleteICON">Delete</a>
        </div>

    </li>';

```

Problem was that , you have to close echo before foreach and after foreach start a new echo. same logic is working fine with my code. Hope this also.