2016-07-08 7 views
0

の値をエコーし​​ます。私はそれを試しました:は、私はこのコードを持っているforeachループ

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

} 

私はいくつかの兆候に間違いがあると思います。あなたには、いくつかの構文的なミスが一度

+2

あなたがPHP [文字列構文]を学ぶ必要がある(http://php.net/manual/en/language.types.string.php#language.types.string.syntax.single) –

答えて

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

} 

を使用してください。連結文字列に

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

ありがとうございます! – Hertus

0

これをチェックしてい

関連する問題