Q:

Echo out values in foreach loop

I have this code:
 if(!empty($item['criteria'])){
            foreach ($item['criteria'] as $item2){
             echo "$item2[description]<br/>".PHP_EOL;
            }
        }

}

Now i need to modify this code to swing open the $item2[description]. I tried it like that:
if(!empty($item['criteria'])){
            foreach ($item['criteria'] as $item2){
             echo '<a href="javascript:toggle(', $item2['id'], ')">'Click</a>
             <div id="', $item2['id'], '" style="display: none">', $item2['description'], '</div>';
            }
        }

}

I think there is a mistake in some signs.

A:

if(!empty($item['criteria'])){
            foreach ($item['criteria'] as $item2){
             echo '<a href="javascript:toggle('. $item2['id']. ')">Click</a>';
             echo '<div id="'. $item2['id'].'" style="display: none">'. $item2['description'].'</div>';
            }
        }

}

you have some syntactical mistakes check this once

