0

foreach に「行内の foreach に無効な引数が指定されました ...」という問題があります。

これは私が取り組んでいるコードです:

    protected function jsGenerateResourcesAutocomplete(){
    $employeeNames = $this->employeeNames;
    $html = "";
    $html .= '<script>' . PHP_EOL;
    $html .= 'var employeeNames = [' . PHP_EOL;
    foreach( $employeeNames as $employeeName ){
        $html .= '"' . $employeeName->getEmployeeName() . '",' . PHP_EOL;
    }
    $html .= '];' . PHP_EOL;
    $html .= '$(function() {' . PHP_EOL;
    $html .= '$(#resource-input input:text").each(function() {' . PHP_EOL;
    $html .= '$(this).autocomplete({source: employeeNames});' . PHP_EOL;
    $html .= '})' . PHP_EOL;
    $html .= '})' . PHP_EOL;
    $html .= '</script>' . PHP_EOL;
    return $html;
}

この行では、foreach( $employeeNames as $employeeName ){がエラーをスローします。これの何が問題なのですか?

4

1 に答える 1