Home  >  Article  >  Backend Development  >  施用数组元素出现Notice: Undefined offset

施用数组元素出现Notice: Undefined offset

WBOY
WBOYOriginal
2016-06-13 13:24:021017browse

使用数组元素出现Notice: Undefined offset:
$file1打开的是一个这种格式的文件:1|23|4|123|1 
$line=fgets($file1);
$a_line=str_getcsv($line,"|");
print_r($a_line);  
$a_line[4]=$a_line[4]+$a_line[3]-1;
我在使用$a_line[4],$a_line[3]的时候运行会出现Notice: Undefined offset:;
但是上面的print_r($a_line);可以打印出Array ( [0] => 1 [1] => 23 [2] => 4 [3] => 123 [4] => 1 )
不知道为什么?

------解决方案--------------------
$a_line['4']=$a_line['4']+$a_line['3']-1;
------解决方案--------------------

探讨

$a_line['4']=$a_line['4']+$a_line['3']-1;

------解决方案--------------------
不会出现你说的现象
请把错误信息贴全了
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn