0

Given below is my $Array. Empty part shows no files in folder:

    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
                        )



                )

        )

I want to show it in html table : enter image description here

I tried below code but it's not working with data table so any other option or logic.

<?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 }?>

Thank you for seeing my question. It will be great help if you will give me answer for this question.

2 Answers 2

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>
                <?}
            }
        }
     }?>
Sign up to request clarification or add additional context in comments.

Comments

0

Try with this,

$array = explode('/', $value2[0]);
echo $array[count($array) -1];

1 Comment

my code already working but it gives me error with datatables : unknow parameter 0 for raw 1 in datatable.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.