PHP 注意:未定义的偏移量:读取数据时带数组的偏移量为 1
2022-08-30 08:13:33
我收到此 PHP 错误:
PHP Notice: Undefined offset: 1
下面是抛出它的 PHP 代码:
$file_handle = fopen($path."/Summary/data.txt","r"); //open text file
$data = array(); // create new array map
while (!feof($file_handle) ) {
$line_of_text = fgets($file_handle); // read in each line
$parts = array_map('trim', explode(':', $line_of_text, 2));
// separates line_of_text by ':' trim strings for extra space
$data[$parts[0]] = $parts[1];
// map the resulting parts into array
//$results('NAME_BEFORE_:') = VALUE_AFTER_:
}
此错误是什么意思?导致此错误的原因是什么?