doujing6053 2014-12-11 12:09
浏览 68

在echo中间回显if语句

I have a code with checkbox like:

Echo "<p>Some text go here (I NEED TO PUT HERE CHECKBOX CHECKED FROM IF), here goes another text.</p>"

if( isset( $_POST['check'] ))
{
    if( count( $_POST['check'] ) > 0 )
    {
        echo "" . implode(", ", $_POST['check']);
    }

I need to put the if from checkbox array in the middle of my echo, theres a way?

Tks

  • 写回答

1条回答 默认 最新

  • dounouxi1020 2014-12-11 12:14
    关注

    If you assign the value to a variable, you can concetanate (ugh! this word...) it to one echo command.

    if( isset( $_POST['check'] ))
    {
        if( count( $_POST['check'] ) > 0 )
        {
            $var = implode(", ", $_POST['check']);
        } else {
            $var = "";
        }
    
    echo "<p>Some text go here" . $var . ", here goes another text.</p>";
    

    Edit

    Added Mark's comment, as a more efficient way of the above echo command:

    echo "<p>Some text go here", $var, ", here goes another text.</p>";
    
    评论

报告相同问题?

悬赏问题

  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统