Print an array of dates

0
Array 
(  
  [Monday] => Array
  (
    [0] => 2017-07-03
    [1] => 2017-07-17
    [2] => 2017-07-31
  )

  [Friday] => Array
  (
    [0] => 2017-06-30
    [1] => 2017-07-14
    [2] => 2017-07-28
  )
)

My goal is to get a list of dates like this:

        2017-07-03
        2017-07-17
        2017-07-31
        2017-06-30
        2017-07-14
        2017-07-28
    
asked by Luis 03.07.2017 в 17:29
source

3 answers

1

you can iterate the array:

foreach (Array as $key=> $values) {
    foreach ($values as $value) {
        echo "$value<br>";
    }
}

In this simple way you can print the value of sub-level 2 of the array.

    
answered by 03.07.2017 / 17:35
source
1

A typical solution is with foreach, assuming that the array is $dias :

foreach($dias as $dia) {

    foreach ($dia as $fecha) {

        echo $fecha . '<br>';

    }

}
    
answered by 03.07.2017 в 17:36
0

Another possibility would be to use the function implode() :

$arrayDays = [

    'Monday' => [ '2017-07-03', '2017-07-17', '2017-07-31' ],
    'Friday' => [ '2017-06-30', '2017-07-14', '2017-07-28' ]
];

foreach( $arrayDays as $date ) {

    echo implode( PHP_EOL, $date ).PHP_EOL;
}

See Demo

    
answered by 03.07.2017 в 20:03