在foreach循环中回显值[关闭]

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.

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

Use the . to concat strings

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>';
    }
}