以下是我的$ Array。空白部分在文件夹中不显示任何文件:
Array
(
[16A] => Array
(
[2014-2015] => Array
(
[Q1] => Array
(
[0] => ../webroot/files/16A/2014-2015/Q1/AAAAA2005Q_Q1_AY201415_16A.pdf
)
[Q2] => Array
(
)
[Q3] => Array
(
)
[Q4] => Array
(
)
)
[2016-2017] => Array
(
[Q1] => Array
(
)
[Q2] => Array
(
)
[Q3] => Array
(
[0] => ../webroot/files/16A/2016-2017/Q3/AAAAA2005Q_Q3_AY201617_16A.pdf
[1] => ../webroot/files/16A/2016-2017/Q3/AAACB6215D_Q3_AY201617_16A.pdf
[2] => ../webroot/files/16A/2016-2017/Q3/AAACB7821R_Q3_AY201617_16A.pdf
[3] => ../webroot/files/16A/2016-2017/Q3/AAACC6356N_Q3_AY201617_16A.pdf
[4] => ../webroot/files/16A/2016-2017/Q3/AAACE7722Q_Q3_AY201617_16A.pdf
)
)
)
我尝试了下面的代码,但它没有使用数据表,所以任何其他选项或逻辑。
<?php foreach ($Array as $key => $value) { ?>
<?php foreach ($value as $key1 => $value1) { ?>
<?php foreach ($value1 as $key2 => $value2) { ?>
<tr class="active">
<?php if($value2){?>
<td><?php echo $key ?></td>
<td><?php echo $key1 ?></td>
<td><?php echo $key2 ?></td>
<td><?php if($value2){
$array = explode('/', $value2[0]);echo $array[count(explode('/', $value2[0])) -1];} ?></td>
</tr>
<?php } }?>
<?php }?>
<?php }?>
感谢您查看我的问题。如果你能回答这个问题,那将会很有帮助。
答案 0 :(得分:1)
<?php foreach ($Array as $key => $value){ ?>
<?foreach ($value as $key1 => $value1){?>
<?foreach ($value1 as $key2 => $value2){?>
<? if ($value2){ ?>
<tr class="active">
<td><?=$key ?></td>
<td><?=$key1 ?></td>
<td><?=$key2 ?></td>
<td><?if ($value2)
{
$array = explode('/', $value2[0]);
echo $array[count(explode('/', $value2[0])) - 1];
} ?>
</td>
</tr>
<?}
}
}
}?>
答案 1 :(得分:0)
试试这个,
$array = explode('/', $value2[0]);
echo $array[count($array) -1];