Use foreach to display array data within an array

3

I am using the CCv5 and CFv5 components (from chronoengine) within the latest version of Joomla 3.x to, first, get information from different tables and now what I need is to show some of the information with a foreach ( or similar).

Specifically, these are the arrays I have and I want to show all the information of the array named Data12:

Array
(
    [cont] => lists
    [ccname] => monlistado
    [act] => edit
    [gcb] => 1
    [CCT] => Array
        (
            [id] => 1
            [uniq_id] => 726a43b057c4efa01756d64336e0c037f9e4eb78
            [user_id] => 660
            [created] => 2017-09-30 18:00:38
            [modified] => 2017-10-01 16:42:15
            [modified_userid] => 661
            [s01p04id_investigador] => investigador
            [s01p04monitor] => 661
            [s01p04id_paciente] => in31ve3691
            [s01p01notasdeseccion] => Notas de ejemplo de la sección
            [s01p01tipopaciente] => 1
            [s01p01fecha_de_nacimiento] => 09-05-2007
            [s01p01fecha_de_ingreso] => 13-09-2017
            [s01p01s01p01fecha_de_ingreso_ninv] => esta es una nota
            [s01p02s01p01fecha_de_ingreso_nmon] => 
            [s01p02s01p01fecha_de_ingreso_q] => 0
            [s01p01edad] => 10
            [s01p01peso] => 80
            [s01p01talla] => 180
            [s01p01imc] => 24.69
        )

    [Data12] => Array
        (
            [0] => Array
                (
                    [created] => 2017-09-30 18:00:39
                    [s01p04monitor] => 661
                    [s01p01s01p01fecha_de_ingreso_ninv] => notas
                    [s01p02s01p01fecha_de_ingreso_nmon] => 
                )

            [1] => Array
                (
                    [created] => 2017-09-30 18:01:52
                    [s01p04monitor] => 661
                    [s01p01s01p01fecha_de_ingreso_ninv] => 
                    [s01p02s01p01fecha_de_ingreso_nmon] => notas
                )

        )

)

How do I do it?

    
asked by Nicolau Roca 03.10.2017 в 01:43
source

1 answer

1

Depending on what the OP explains in the comments, it could be done with a foreach (assuming the array is called $ myArray):

foreach ($myArray['Data12'] as $data) {

    echo $data['created'] . '<br>';

    echo $data['s01p01s01p01fecha_de_ingreso_ninv'] . '<br>';

    echo $data['s01p02s01p01fecha_de_ingreso_nmon'] . '<br>';

}

This is just an example, in terms of the html part, you can handle the tags you want or create a table, etc.

    
answered by 03.10.2017 в 02:06