我试图从csv获取数据以使用php显示。这是代码
int miscellaneous::printWelcomeScreen()
{
int ch = 0;
cout<<"Tic Tac Toe"<<endl<<endl;
cout<<"1. Play Game "<<"2. How to Play "<<"3. Credits "<<endl;
cout<<endl<<"Enter Your Choice"<<endl;
cin >> ch;
if(cin.fail() != 0)
{
std::cout << "Hey! That's not valid input! Try again.\n\n"
cin.clear();
cin.ignore(10000,'\n');
}
cout << " ch = " << ch << endl;
choiceSelection(ch);
return 0;
}
我正在收到输出但收到通知msg:
注意:未定义的偏移量:2
如何解决?
答案 0 :(得分:1)
如果您不想查看该文件,可以执行以下操作:
$file_handle = fopen("dept.csv", "r");
while (!feof($file_handle) ) {
$line_of_text = fgetcsv($file_handle, 1024);
print ($line_of_text[0]) . " ". ($line_of_text[1]);
if (isset($line_of_text[2]))
print($line_of_text[2]);
print ("<BR>");
}
fclose($file_handle);