Home > Article > Backend Development > 报错Notice: Undefined offset: 1
<?PHP include("conn.php"); if(isset($_POST['text'])) { $text=$_POST['text']; $t = date('Ymd', strtotime("-$text day")); } else { $t = date('Ymd', strtotime('-5 day')); } //warehouse_mix.txt $hk_warehouse = array();foreach(glob('download/hk_warehouse_mix*.txt') as $hk_warehouse_fn) { if(substr($hk_warehouse_fn, 16, 8)>$t) { $hk_warehouse[] = $hk_warehouse_fn; }}$jp_warehouse=array();foreach(glob('download/jp_warehouse_mix*.txt') as $jp_warehouse_fa) { if(substr($jp_warehouse_fa, 16, 8)>$t) { $jp_warehouse[] = $jp_warehouse_fa; }}$mix_warehouse=array();foreach(glob('download/mix_warehouse_mix*.txt') as $mix_warehouse_fa) { if(substr($mix_warehouse_fa, 17, 8)>$t) { $mix_warehouse[] = $mix_warehouse_fa; }}$sum_warehouse=array();foreach(glob('download/sum_warehouse_mix*.txt') as $sum_warehouse_fa) { if(substr($sum_warehouse_fa, 17, 8)>$t) { $sum_warehouse[] = $sum_warehouse_fa; }}//warehouse_mix_label.pdf$hk_warehouse_pdf = array();foreach(glob('download/hk_warehouse_mix*.pdf') as $hk_warehouse_pdf_fn) { if(substr($hk_warehouse_pdf_fn, 16, 8)>$t) { $hk_warehouse_pdf[] = $hk_warehouse_pdf_fn; }}$jp_warehouse_pdf=array();foreach(glob('download/jp_warehouse_mix*.pdf') as $jp_warehouse_pdf_fa) { if(substr($jp_warehouse_pdf_fa, 16, 8)>$t) { $jp_warehouse_pdf[] = $jp_warehouse_pdf_fa; }}$mix_warehouse_pdf=array();foreach(glob('download/mix_warehouse_mix*.pdf') as $mix_warehouse_pdf_fa) { if(substr($mix_warehouse_pdf_fa, 17, 8)>$t) { $mix_warehouse_pdf[] = $mix_warehouse_pdf_fa; }}//pdf_mix $hk_pdf = array();foreach(glob('download/HK_print_Mix*.pdf') as $hk_pdf_fn) { if(substr($hk_pdf_fn, 12, 8)>$t) { $hk_pdf[] = $hk_pdf_fn; }}$jp_pdf=array();foreach(glob('download/JP_print_Mix*.pdf') as $jp_pdf_fa) { if(substr($jp_pdf_fa, 12, 8)>$t) { $jp_pdf[] = $jp_pdf_fa; }}$mix_pdf=array();foreach(glob('download/Mix_print_Mix*.pdf') as $mix_pdf_fa) { if(substr($mix_pdf_fa, 13, 8)>$t) { $mix_pdf[] = $mix_pdf_fa; }}//pdf_mix_A4$hk_pdf_a4 = array();foreach(glob('download/HK_print_Mix_A4_*.pdf') as $hk_pdf_a4_fn) { if(substr($hk_pdf_a4_fn, 16, 8)>$t) { $hk_pdf_a4[] = $hk_pdf_a4_fn; }}$jp_pdf_a4=array();foreach(glob('download/JP_print_Mix_A4_*.pdf') as $jp_pdf_a4_fa) { if(substr($jp_pdf_a4_fa, 16, 8)>$t) { $jp_pdf_a4[] = $jp_pdf_a4_fa; }}$mix_pdf_a4=array();foreach(glob('download/Mix_print_Mix_A4_*.pdf') as $mix_pdf_a4_fa) { if(substr($mix_pdf_a4_fa, 17, 8)>$t) { $mix_pdf_a4[] = $mix_pdf_a4_fa; }}//统计每类文件的数量,以便循环$hk_warehouse_count=count($hk_warehouse);$jp_warehouse_count=count($jp_warehouse);$mix_warehouse_count=count($mix_warehouse);$sum_warehouse_count=count($sum_warehouse);$hk_warehouse_pdf_count=count($hk_warehouse_pdf);$jp_warehouse_pdf_count=count($jp_warehouse_pdf);$mix_warehouse_pdf_count=count($mix_warehouse_pdf);$hk_pdf_count=count($hk_pdf);$jp_pdf_count=count($jp_pdf);$mix_pdf_count=count($mix_pdf);$hk_pdf_a4_count=count($hk_pdf_a4);$jp_pdf_a4_count=count($jp_pdf_a4);$mix_pdf_a4_count=count($mix_pdf_a4);$c=max($hk_warehouse_count,$jp_warehouse_count,$mix_warehouse_count,$sum_warehouse_count,$hk_warehouse_pdf_count,$jp_warehouse_pdf_count,$mix_warehouse_pdf_count,$hk_pdf_count,$jp_pdf_count,$mix_pdf_count,$hk_pdf_a4_count,$jp_pdf_a4_count,$mix_pdf_a4_count);echo $c;for($i=1;$i<$c;$i++){ ?> <tr> <td height="31" bgcolor="#FFFFFF"><a href="<?PHP echo $hk_warehouse[$i]; ?>"><?PHP echo substr($hk_warehouse[$i], 16, 5); ?></a></td> <td bgcolor="#FFFFFF"><a href="<?PHP echo $jp_warehouse[$i]; ?>"><?PHP echo substr($jp_warehouse[$i], 16, 5); ?></a></td> <td bgcolor="#FFFFFF"><a href="<?PHP echo $mix_warehouse[$i]; ?>"><?PHP echo substr($mix_warehouse[$i], 17, 5); ?></a></td> <td bgcolor="#FFFFFF"><a href="<?PHP echo $sum_warehouse[$i]; ?>"><?PHP echo substr($sum_warehouse[$i], 17, 5); ?></a></td> <td bgcolor="#FFFFFF"> </td> <td bgcolor="#FFFFFF"> </td> <td bgcolor="#FFFFFF"> </td> <td bgcolor="#FFFFFF"> </td> <td bgcolor="#FFFFFF"> </td> <td bgcolor="#FFFFFF"> </td> <td bgcolor="#FFFFFF"> </td> <td bgcolor="#FFFFFF"> </td> <td bgcolor="#FFFFFF"> </td> </tr> <?PHP } ?>
你怎么知道
$hk_warehouse_count,$jp_warehouse_count,$mix_warehouse_count,$sum_warehouse_count,$hk_warehouse_pdf_count,$jp_warehouse_pdf_count,$mix_warehouse_pdf_count,$hk_pdf_count,$jp_pdf_count,$mix_pdf_count,$hk_pdf_a4_count,$jp_pdf_a4_count,$mix_pdf_a4_count
都大于 0 呢?
xuzuning大大,明白了,我加一个判断