doule6314 2013-08-28 21:52
浏览 15
已采纳

未定义的索引通知会停止脚本

Ok guys this is my code:

if (!is_array($html_strings[$form_name])) {$html_strings[$form_name] = array();}
        array_push($html_strings[$form_name], "<input type='checkbox' ".
                                                " name='" . $result{"formdir"} . "_" . $result{"form_id"} . "'".
                                                " id='" . $result{"formdir"} . "_" . $result{"form_id"} . "'".
                                                " value='" . $result{"encounter"} . "'" .
                                                " class='encounter_form' ".
                                                ">" . xl_form_title($result{"form_name"}) . "<br>
");

and I am getting the following notice "Notice: Undefined index: Nota de Consulta"

Any help on fixing this issue?

  • 写回答

1条回答 默认 最新

  • dongteng2534 2013-08-28 21:56
    关注

    $html_strings['Nota de Consulta'] seems to be not defined yet, so you can't use is_array on it.

    You can check if $html_strings[$form_name] exists, before checking it for being an array:

    if (!isset($html_strings[$form_name]) || !is_array($html_strings[$form_name])) {
        $html_strings[$form_name] = array();
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?